String Shortening in Mail Merges

This caused me some headaches today, so to save you the cost of a box of paracetamols i thought I’d shout it out! If you ever find yourself writing code to perform your own mail merges based on CRM mail merge tags watch out for how CRM shortens mail merge tags when involving related entities. What do I mean by this? Well let’s say we create a mail merge that is based on case. In this merge we include the primary contacts name and address. In doing this we basically add a related field in to our mail merge.

When the lookup fields name on case to contact is short EG “Primary Contact” you wont see any string shortening. If you check a mail merge tag for relating to contacts full name from case in MS Word you will see its <<Primary_Contact_Full_Name>>.

However if you altered this lookup field’s display field to something long EG Primary Contact (For Some Reason I Like Long Names) you won’t see <<Primary_Contact_For_Some_Reason_I_Like_Long_Names_Full_Name>> for a contacts full name. The string will be shorted to 19 characters before the _ that seperates related field name and field name. In this case your tag will be <<Primary_Contact_For_Full_Name>>.

Leave a Reply

Your email address will not be published. Required fields are marked *