Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Email Description field is getting cleared

Posted on by

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);
        } 
    }
};


*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans