CRMBuzz.net

Abe Saldana on Microsoft Dynamics CRM Development
posts - 19, comments - 5, trackbacks - 0

Email Templates tag merging

I was working on a small project making some changes to the Email Templates when I got the requirements to create some meta tags and implement detail logic that will depend on the value of a field, that was interesting and challenging at the same time and  make that customization been supported by the infrastructure of CRM, well I made changes but these are unsupported code, these are the steps on how to make the customizations:

1) Make the modifications to ...\Activities\email\edit.aspx file.

2) Update the javascript function ApplyTemplate() and include the functionality required for the customer.

function ApplyTemplate()

{                var oTarget = ChooseTemplateTarget();

                if (oTarget == null)

                return;

                var sUrl = "/_grid/cmds/dlg_bulkemail.aspx?bulkemail=false" + "&objectTypeCode=" + oTarget.otype + "&objectId=" + oTarget.oid;

                var sResponse = openStdDlg(sUrl, null, 550, 850);

                if (sResponse != null)

                {

                                // Get Response from the email template

                                var templatedescription = sResponse.EmailBody ;

                                // Get the contact/account id for searching

                                var ToRecipients = crmForm.all.to.Items();

                                var customerid = ToRecipients[0].id

                                // Get status for the contact/account

                                var validationonBoolean = GetWebServiceValidation(customerid);

                                if (validationonBoolean)

                                {

                                // Customer Validation is TRUE

                                templatedescription = stringReplace(templatedescription,"[LOCALEDMESSAGE]","Replace message with English version");

                                }else

                                {

                                // Customer Validation is FALSE

                                templatedescription = stringReplace(templatedescription,"[LOCALEDMESSAGE]","Replace message with Spanish version");

                                }

                                crmForm.all.description.InsertValue ( templatedescription );

                }

}

 

3) After that I used the normal string.Replace function finding the function only replaced the first instance, that will take me to the second correction and make the following function:

function stringReplace(originalString, findText, replaceText)

{

var pos = 0;

var len = findText.length;

pos = originalString.indexOf(findText);

while (pos != -1)

{

preString = originalString.substring(0,pos);

postString = originalString.substring(pos + len,

originalString.length);

originalString = preString + replaceText + postString;

pos = originalString.indexOf(findText);

}

return originalString;

}

 

The rest was a simple implementation of your Web Services call, please read the previous blog called "How to call my web service using Javascript?"

Remember that this is an Unsupported customization and when a service patch come it will provably remove those customizations.

I hope this information help you to add more flexibility to the email templates.

 

Abe Saldaña

http://www.crmbuzz.net

 

This all is undocumented and unsupported. Therefore you should only try these kinds of modifications if you feel comfortable with this.
Everything here, though, is my personal opinion and is not read nor approved before being posted. No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here. 
 

Print | posted on Thursday, July 26, 2007 9:31 PM | Filed Under [ Client Scripting Code Level 200 Unsupported ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 2 and 3 and type the answer here:

Powered by: