web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

I have the same question (0)
  • Verified answer
    Flydancer Profile Picture
    1,332 on at

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

  • Community Member Profile Picture
    on at

    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
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 60 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 43

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans