Hi,
I have a script on load of email that sets the email From address to a queue. However I added the save event also to the script. Now whenever I click on Reply in the email, the description is getting cleared.
Can anyone please help me with this?
Below is the script I have used to set the From Address:
//Using this script we're setting from field based on the queue value in regarding object.
var CRM = CRM || {};
CRM.EmailEntConfig = {
FormTypes: { Create: 1, QuickCreate: 5, Update: 2, ReadOnly: 3, Disabled: 4 },
Queues: {
SupportQueueName: "Support"
},
IsOnloadFired: false,
SupportQueueID:(GUID),
};
CRM.Email_Onload = function () {
CRM.SetFromField();
CRM.SaveForm();
};
CRM.SaveForm = function () {
var formType = Xrm.Page.ui.getFormType();
var statusValue = Xrm.Page.getAttribute("statuscode")!=null?
Xrm.Page.getAttribute("statuscode").getValue():null;
if ((formType === 1 || formType === 2) && (statusValue!=4 && statusValue!=3)) {
if (Xrm.Page.data.entity.getIsDirty()) {
Xrm.Page.data.entity.save();
}
}
};
//using following function we're setting 'From' field to the Support
CRM.SetFromField = function () {
var objFormType = Xrm.Page.ui.getFormType();
if (objFormType == CRM.EmailEntConfig.FormTypes.Create || objFormType == CRM.EmailEntConfig.FormTypes.Update) {
var objFrom = Xrm.Page.getAttribute("from").getValue();
if (objFrom != null) {
objFrom = objFrom[0].id;
objFrom = objFrom.replace("}", "").replace("{", "").toLowerCase();
}
if (CRM.EmailEntConfig.SupportQueueID == "" || CRM.EmailEntConfig.SupportQueueID == undefined){
return;
}
if (objFrom == null || objFrom.toLowerCase() != CRM.EmailEntConfig.SupportQueueID.toLowerCase()) {
var partyList = new Array();
partyList[0] = new Object();
partyList[0].id = CRM.EmailEntConfig.SupportQueueID;
partyList[0].name = CRM.EmailEntConfig.Queues.SupportQueueName;
partyList[0].entityType = "queue";
Xrm.Page.getAttribute("from").setValue(partyList);
}
}
};