web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

on click of reply, reply all and forward in email message, need to update the description with some content.

(0) ShareShare
ReportReport
Posted on by 104

on click of reply, reply all and forward in email message, need to update the description with some content. I am able to update the content while debugging in console but it is not working while doing by code. calling the below script in onload function. Any help would be appreciated to resolve this.

if (formType == 2) {

var regardingObject = Xrm.Page.getAttribute("regardingobjectid").getValue();
var subject = Xrm.Page.getAttribute("subject").getValue();
if (regardingObject != null && regardingObject != "" && regardingObject != undefined) {
if (regardingObject[0].entityType == "entityname" && (subject.indexOf("RE: ") != -1 || subject.indexOf("FW: ") != -1)) {
includeSignature();
}
}
}


function includeSignature() {
var description = Xrm.Page.getAttribute("description").getValue();
var currentUser = Xrm.Page.context.getUserName();
Xrm.Page.getAttribute("description").setValue("<p style='font-family: Arial; font-size: 10pt;'>Dear <br><br> Please do not reply directly to this email. To reply, please click <a href='url'>link1</a>.<br><br>Best Regards" + "<br>" + currentUser + "<br></p><p style='font-family: Arial; font-size: 8pt;'>Privileged or confidential information may be contained in this email. If you have received this mail in error, please delete it and notify the sender.</p>" + description);
Xrm.Page.getAttribute("description").setSubmitMode("always");
Xrm.Page.data.entity.save();

}

Kindly help me if am missing something.

Thanks

*This post is locked for comments

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Are you getting any error message? Can you share what is exactly happening when you say it not working?

  • Ash06 Profile Picture
    104 on at

    No I am not getting any error message, the description which I am trying to update is not updating. It is showing the existing description not the new one.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    I tried this and got mixed results i.e. it worked sometime but not always. It appears to be an issue with the retrieval of the description field wherein the description is returning null sometimes, I guess CRM is loading the description asynchronously. The other change which I did is to remove the save statement.

    However when I register the event in save even, it worked as expected. Can you register event on save instead of onload and see if it works? You need to remove the save statement from your code-

     Xrm.Page.data.entity.save();

    Hope this helps.

  • Ash06 Profile Picture
    104 on at

    Thanks Ravi.

    I tried this by removing Xrm.Page.data.entity.save(); and called in onload it dint work still. As u said i put that function in onsave, it is working as expected.

    As per my scenario i want this to be updated in onclicking "Reply", "Reply all" and "forward" buttons, i believe this we can achieve using onload only. Is there any way i can do this???? Any help would be appreciated.

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Try putting some timeout before calling the script i.e. say wit for 5-10 seconds and then call your script. Tt worked few time onload for me. I guess when it is able to find the description then it is working fine (Can't say for sure though).

  • Ash06 Profile Picture
    104 on at

    I tried using timeout too, but it is working intermittently. If i debug and check step by step it is updating the description, but other times it didnt. :(

  • Verified answer
    Ash06 Profile Picture
    104 on at

    Thanks for your help, i have resolved this now . I have updated the description content in a dummy field and used the field value to update the description. Also used the timeout particularly while updating the  description field as shown below.

    setTimeout(function () {

           Xrm.Page.getAttribute("description").setValue(finalDesc);        

       }, 0);

    except 2016 version, am able to update email description without timeout in other versions without any issue.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans