Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Adding the from email address to a forward or reply

Posted on by Microsoft Employee

Hey All,

I've written some JavaScript to get the from email address off of the original message and add it to the from field on the forward/reply of the message on load of the forward/reply email. I'm still testing it  and I'm just wondering if anybody has done this?

I ran into a few issues while implementing my solution. The main one being when I set the new value of the description in the email it did not change on the form.

if(currentDescription != null){
   var newDesc = setHeader(currentDescription, email);
   Xrm.Page.getAttribute("description").setValue(newDesc);
}

So from the code above the setHeader function takes the current description and the original senders email address and add the original senders email address to the current description and returns the updated/new description. I then set the value of description to the new description (newDesc). This was not changing the value of the description on the form.

To trouble shoot I got the value of the new description from set header and showed it on the console and it was as expected.

I got the value of the description after I had set it with the new description and showed that on the console and both were the same. See Below.

if(currentDescription != null){
   var newDesc = setHeader(currentDescription, email);
   console.log(newDesc);                      
   Xrm.Page.getAttribute("description").setValue(newDesc);
   var testDesc =  Xrm.Page.getAttribute("description").getValue();
   console.log(testDesc);
}

I then put break points on my code and stepped through the if statement above and it worked!
So I put a timeout of one second before I set the new description and it still works.
if(currentDescription != null){
   var newDesc = setHeader(currentDescription, email);
   setTimeout(() => {Xrm.Page.getAttribute("description").setValue(newDesc)}, 1000);
   //Xrm.Page.getAttribute("description").setValue(newDesc);
}

Does anybody out there have a more elegant solution?


 

Categories:

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

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