JavaScript SET and GET for different fields in Dynamics 365 CRM
JavaScript SET and GET for different fields in Dynamics 365 CRM: -
When event triggers then it passes “execution context” as the first parameter to the JavaScript function.
We can enable and disable this by clicking on the checkbox for Pass execution context as the first parameter.
Firstly, we need to create a form context from execution context.
Below JavaScript code will do that,
After creating the “formContext” we can get the form fields data from it.
Single Line of Text: -
GET method: -
SET method: -
Two Option set: -
GET method: -
SET method: -
We should use values as “true” or “false” for two option set.
Option set: -
To get option set value, return type is number
To get option set Text, return type is string
getOptions() method will return an Array of Option Objects with “text” and “value” as keys.
Lookup field: -
Lookup data is an array of object, which contains keys as “id”, “entityType”, “name”
Set Lookup field: -
To set lookup field firstly we need to create an array and inside that array create an object, in that object add “id”, “entityType”, “name” key-value pairs
Note: - We can only add one object to lookup array, if give more than one then shows an error.
Comments
Post a Comment