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?