This post is a part of a series of posts for Customer Service. The complete GUIDE can be found here
Every time I setup Customer Service I encounter the same 2 problems.
1. I want to send from a QUEUE
2. I need to automatically add a signature
Am I really the only one having these problems, or are we all doing the same silly tasks every time?
Standard Signature OOTB

You can enter a standard signature per user, but this signature does not support HTML formatting for some reason. The email you are writing to is in fact a HTML email. Signature that is injected is text into a HTML, but the signature editor is a simple text editor.
When we open the email, the default signature will appear.
Pluss | Minus |
1. You can use standard MS functions to auto insert signature 2. Users can easily make changes to personal signature. | 1. Does not support HTML formatting of signature 2. Every user can configure personal signature, and you can’t control it for company profiling. 3. If you work with customer service you have to 4-5 clicks to find the correct signature for Customer Service to enter. |

Standard Sender FROM
Whenever you open an email in Dynamics it will default to your email address. Normally I would say this if fine, but why on earth would you want to do this when setting up a Customer Service system?

A user would have to change the FROM to the Customer service

Imagine having to do this every single time you want to answer an email in Dynamics Customer Service! I personally would go crazy.
Design
I solve this by creating a custom entity called Signature and use a standard field on User “Default Queue” to solve the 2 problems. This involves some javascript, but will provide everything you need. In my last post of this series, I will also include the managed and unmanaged files you need to do it yourself.

From the Email I will now retrieve the HTML signature and default sender for this contact.
1. HTML Signature
I found this little tool that generates an HTML signature. It seems like a cool little piece of free software that will create nice HTML signatures. The HTML you generate, can be copy pasted directly into the signature entity.

After messing about for a while I got the following result.

Example HTML
<table width="351" cellspacing="0" cellpadding="0" border="0"> <tr> <td style="vertical-align: top; text-align:left;color:#000000;font-size:12px;font-family:helvetica, arial;; text-align:left"> <span><span style="margin-right:5px;color:#000000;font-size:15px;font-family:helvetica, arial">Customer Service Team</span> <br><span style="margin-right:5px;color:#000000;font-size:12px;font-family:helvetica, arial">Super Duper Helper</span></span> <br> <span style="font:12px helvetica, arial;">E-mail <a href="mailto:support@support.com" style="color:#3388cc;text-decoration:none;">support@support.com</a></span> <br> <span style="font:12px helvetica, arial;">Telephone <span style="color:#000000">22222222</span></span> <br> <table cellpadding="0" cellpadding="0" border="0"><tr><td style="padding-right:5px"><a href="https://facebook.com/https://www.facebook.com/pointtakenas" style="display: inline-block;"><img width="40" height="40" src="https://s1g.s3.amazonaws.com/d927102059ee8fca87e6e3f49e77e9e9.png" alt="Facebook" style="border:none;"></a></td><td style="padding-right:5px"><a href="https://twitter.com/https://twitter.com/point_taken_" style="display: inline-block;"><img width="40" height="40" src="https://s1g.s3.amazonaws.com/83255843bbcec47d809669aff3b22691.png" alt="Twitter" style="border:none;"></a></td><td style="padding-right:5px"><a href="https://linkedin.com/company/https://www.linkedin.com/company/pointtaken-as" style="display: inline-block;"><img width="40" height="40" src="https://s1g.s3.amazonaws.com/85f05a94630abd611533bc2566751eb7.png" alt="LinkedIn (Company)" style="border:none;"></a></td><td style="padding-right:5px"><a href="https://youtube.com/https://www.youtube.com/channel/UC4rPzEDfHPp393oqOozUqaw" style="display: inline-block;"><img width="40" height="40" src="https://s1g.s3.amazonaws.com/a6f64a587978d338c0b8f6cc2d90bd0b.png" alt="YouTube" style="border:none;"></a></td><td style="padding-right:5px"><a href="https://instagram.com/https://www.instagram.com/pointtakenas/" style="display: inline-block;"><img width="40" height="40" src="https://s1g.s3.amazonaws.com/05f979c6025f3a336303ec824ebb815c.png" alt="Instagram" style="border:none;"></a></td></tr></table><a href="https://www.pointtaken.no" style="text-decoration:none;color:#3388cc;">www.pointtaken.no</a> </td> </tr> </table>
Next you click on COPY HTML and open the Support Signature record (CUSTOM) on the user entity.

Just copy paste the HTML right inn to the text area. Save and Close
2. Javascript
Now you have to create a JavaScript file on the Email form. In the solution you can download in my last post you will find that I add a form to Email that you can use. I chose not to overwrite the default form.


var formContext = "";
function OnCrmPageLoad(executionContext) {
formContext = executionContext.getFormContext();
//
//You don't need to change this. Just understand that forms have one the following states when opening
//
var FormTypes =
{
Undefined: 0,
Create: 1,
Update: 2,
ReadOnly: 3,
Disabled: 4,
QuickCreate: 5,
BulkEdit: 6
}
runAlways(formContext);
switch (formContext.ui.getFormType()) {
case FormTypes.Create: OnNewFormLoad(); break;
case FormTypes.Update: OnUpdateFormLoad(); break;
case FormTypes.ReadOnly: OnReadOnlyFormLoad(); break;
case FormTypes.Disabled: OnDisabledFormLoad(); break;
case FormTypes.QuickCreate: OnQuickCreateFormLoad(); break;
case FormTypes.BulkEdit: OnBulkEditFormLoad(); break;
case FormTypes.Undefined: alert("Error"); break;
}
}
//
//I only use the RunAlways, OnNewFormLoad and OnUpdateFormLoad, but i keep the others here if i ever would need.
//When looking at this you can always know what funtion is running. Easy to read and debug.
//On my OnNewFOrmLoad I am now calling a function "GetDefaultQueueAndSignature"
//
function runAlways() { }
function OnNewFormLoad() {
GetDefaultQueueAndSignature();
}
function OnUpdateFormLoad() {
GetDefaultQueueAndSignature();
}
function OnReadOnlyFormLoad() { }
function OnDisabledFormLoad() { }
function OnQuickCreateFormLoad() { }
function OnBulkEditFormLoad() { }
//
//CUSTOM FUNCTIONS are added below here. Below this point you add all types of functions you need.
//
function GetDefaultQueueAndSignature() {
//Get User GUID and replace "{" and "}" with blanks.
var UserID = Xrm.Utility.getGlobalContext().userSettings.userId;
UserID = UserID.replace("{", "");
UserID = UserID.replace("}", "");
//Get User Default Queue and Signature via WebApi
Xrm.WebApi.online.retrieveRecord("systemuser", UserID, "?$select=_queueid_value&$expand=cs_Signature($select=cs_htmlsignature)").then(
function success(result) {
var Id = "{" + result["_queueid_value"] + "}";
var Name = result["_queueid_value@OData.Community.Display.V1.FormattedValue"];
var LogicalName = result["_queueid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
if (result.hasOwnProperty("cs_Signature")) {
var Signature = result["cs_Signature"]["cs_htmlsignature"];
}
if (LogicalName == null || Signature == null) {
alert("User Record missing Queue and/or Signature");
return;
}
//Set FROM lookup to queue
formContext.getAttribute("from").setValue([{ id: Id, name: Name, entityType: LogicalName }]);
//Set signature before current text in body
var Body = formContext.getAttribute("description").getValue();
if(Body != null){
formContext.getAttribute("description").setValue("<br /><br />" + Signature + Body);
}else{
formContext.getAttribute("description").setValue("<br /><br />" + Signature);
}
},
function (error) {
Xrm.Utility.alertDialog(error.message);
}
);
}
Save and publish.
The Result is beautiful

We have now saved the service technician many clicks, and the signature looks great. Follow the next post to see how we manage the subject field to “master” the Smart Matching function.
Thanks for your Tuto. I have a question here. If I click in “+” from Case and then “Email”, a new windows appaer (first “Onload”), the signature will apear, but when I click “send ” in Email (send “OnLoad”), the email will be send with two Signature.
But if I click “reply” ( not + then “email”) no problem
LikeLike
Great spot. I lately added a boolean to email with “signature added” to avoid this problem. Added a line to the script that checks if signature is added. It’s not sexy, but it works:)
I haven’t had time to update the blog yet.
LikeLike
Yes , it work. Thanks
LikeLike
Does this script also change the name of the supporter which created the email “super support helper”?
LikeLike
You could add a single line to the signature that would get the name, but that would have to be done in the javascript.
LikeLike