Getting and Setting a Dynamics CRM Field in JavaScript

Leave a comment

To get and set a Dynamics 365 field, first find out the field name. Open the form and find the field, for example on the leads form, the topic:

Double click the field and see what the Name is, in this case “subject”:


function UpdateField() {

var s = Xrm.Page.getAttribute("subject").getValue();

Xrm.Page.getAttribute("subject").setValue("Hello World");

var s = Xrm.Page.getAttribute("subject").getValue();


When this runs we see first the original topic:

Then the new topic:

Field is updated:

This can also be used to check if the field is empty.


Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, BI, Web, Cloud and Data Science.

carldesouza.comLinkedIn Twitter | YouTube


Leave a Reply

Your email address will not be published. Required fields are marked *