Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Unanswered

formContext.data.save() method clears email body

(1) ShareShare
ReportReport
Posted on by 25

Hello everyone,

I have written a custom JS script to apply a value to a hidden field on the Email entity form and then save it with JS, however, after some tests I have discovered that the body of the email as well as Subject are being cleared. Have anyone encountered the same problem and are there any suggestions/ ideas what could be wrong? I have also tried to use the Xrm.Page method, but as I understood it is deprecated and that the formContext.data.save() method should be used instead.

Here's the JS script:

function setfield(executionContext) {

    var formContext = executionContext.getFormContext();
    console.log("setFieldValue");
    var createdBy = Xrm.Page.getAttribute('createdby').getValue();
    var bcc = Xrm.Page.getAttribute('FIELD').setValue(createdBy);
    formContext.data.save();

    }

By the way the CRM is on-premise 8.2 version (8.2.2.112)

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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans