Getting and Setting values for different data types in Dynamics 365 using JavaScript

javascript
var formContext = executionContext.getFormContext(); // Get the form context // Get and set values for different data types var textFieldValue = formContext.getAttribute("textfield").getValue(); var booleanFieldValue = formContext.getAttribute("booleanfield").getValue(); var integerFieldValue = formContext.getAttribute("integerfield").getValue(); var decimalFieldValue = formContext.getAttribute("decimalfield").getValue(); var datetimeFieldValue = formContext.getAttribute("datetimefield").getValue(); var lookupFieldValue = formContext.getAttribute("lookupfield").getValue(); // Set new values for different data types formContext.getAttribute("textfield").setValue("New Text Value"); formContext.getAttribute("booleanfield").setValue(true); formContext.getAttribute("integerfield").setValue(42); formContext.getAttribute("decimalfield").setValue(3.14); formContext.getAttribute("datetimefield").setValue(new Date()); formContext.getAttribute("lookupfield").setValue([{ id: "12345", entityType: "entityTypeCode" }]);

Note: Replace "textfield", "booleanfield", "integerfield", "decimalfield", "datetimefield", and "lookupfield" with the actual logical names of the fields you want to work with. Additionally, make sure you have the necessary permissions to access and modify the fields' values.


Comments

Popular posts from this blog

Power Automate - Update Child record when parent record is updated by using power automate in MS Dynamics CRM

Create Folder On Share Point by using Power Automate In Dynamics CRM

Duplicate Detection Plugin code for Microsoft dynamics CRM