Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to update a field in dynamics 365 form using js code

(0) ShareShare
ReportReport
Posted on by

I have the below js code  i used in the button using ribbon benchwork  and i want  automatically to update the status field to completed if users clicks on that button , but it is not working.

 function (executioncontext) {
"use strict";
var formContext = executioncontext.getFormContext();

if (formContext !== null) {

 formContext.getControl('azmdc_AZstatus').setValue === 100000003;               //   AZstatus is a choice column  and itx value 100000003 = completed



}

}

im not sure if above code correct to update the field, please let me know if need to change anything here. thanks

  • Verified answer
    Pradeep Rai Profile Picture
    5,487 Super User 2025 Season 1 on at
    RE: How to update a field in dynamics 365 form using js code

    HI,

    If you are adding the button on Form then you need pass execution context as described in below link:

    https://d365demystified.com/2020/09/22/pass-execution-context-to-js-script-function-as-a-parameter-from-a-ribbon-button-in-dynamics-365-ribbon-workbench/

    Once you pass this you will able to get the formcontext and above code will work.

    Thanks,
    Pradeep.

    Please mark this as VERIFIED if it helps.

  • Community Member Profile Picture
    on at
    RE: How to update a field in dynamics 365 form using js code

    The above code works fine if i add on save of the form,,but when I add button using ribbon benchwork it doesn't work

  • Verified answer
    Flydancer Profile Picture
    1,332 on at
    RE: How to update a field in dynamics 365 form using js code

    You need to use formContext.getAttribute('azmdc_AZstatus').setValue(100000003)

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Holly Huffman Profile Picture

Holly Huffman 103

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 96 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 51 Most Valuable Professional

Product updates

Dynamics 365 release plans