Put user first name in escalation emails in place of full name that comes by default

By | June 16, 2012

Email action on escalation rules can be used to send emails of escalations, when some criterion becomes true. We always make use of standard case entity fields in the email template to merge the actual values from case table. Now when we put #case_Assigneduserid# in email template or any such user field, it gets automatically replaced by full name of the user, but how if I want to add only first name and not full name. The machine on which we were trying this had only escalation service running and not the CRM notifications. In case of CRM notifications escalation emails fire as soon as notification is displayed on screen, however in case of escalation service mails are sent after some specific time interval which works outside the system. Coming back to our requirement, we can modify our  escalation view vEscalationCases under Administration à Customization à Cases à Views as given below.
CREATE VIEW vEscalationCases AS SELECT Escalations.* , Cases.*,
A.user_firstname as case_ufirstname,
FROM Escalations
LEFT JOIN Cases ON Escl_RecordID = Case_CaseID
LEFT JOIN Users A ON case_assigneduserid = user_userid
WHERE Escl_TableID = 3 AND Escl_Deleted IS NULL

You can see we have put join on Users table through case_assigneduserid field and and aliased the combination of first name and last name as case_ufullname. Then in your email template in place of #case_Assigneduserid# you can put # case_ufirstname#. The emails will be sent with first name in place of the newly added hash field. Also a strange problem we observed is that this method doesn’t work unless and until you have your alias name with prefix as case_ hence we put alias name as case_ufirstname.