Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Set field value using js but it is not saved

Posted on by Microsoft Employee

Hi

On a form in dynamics crm (I set the field as readonly) , I set a field on load event of form as below :

Xrm.Page.getAttribute('description').setValue("2");

But when I go to view of the record, the field I set is still empty. So I tried the following code:

Xrm.Page.getAttribute('description').setValue("2");
Xrm.Page.getAttribute('description').setSubmitMode("dirty")

var save = true;
Xrm.Page.data.refresh(save);

But still it does not save the data.

*This post is locked for comments

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Set field value using js bot it is not saved

    Hi Babak,

    As told by Guido, if you want to save a read-only field, you need to set the SubmitMode to be always which ensures the value is sent to the database. 

    Please try the following code.

    Xrm.Page.getAttribute('description').setSubmitMode("always");

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans