JavaScript - GetValue for different datatypes
JavaScript syntax to get values for different datatypes :
function getFieldValues(executionContext) {
var formContext = executionContext.getFormContext();
//Single line of text -> returns string value
var textField = formContext.getAttribute("new_field1").getvalue(); //output - string
//Whole Number or integer or currency || //output - 10 int/decimal/currency
var wholeNumberField = formContext.getAttribute("new_field2").getvalue();
//Two option || //output - true / false
var twoOptionField = formContext.getAttribute("new_field1").getvalue();
//Optionset || //output - returns optionset code number
var optionSetField = formContext.getAttribute("new_field1").getvalue();
//multi select || //output - returns array of optionset codes [10,12,23]
var multiSelectField = formContext.getAttribute("new_field1").getvalue();
//Lookup || //output - returns lookupObject
var lookupField = formContext.getAttribute("new_field1").getvalue();
if (lookupField != null) {
var id = lookupField[0].id; //returns GUID of record
var entityname = lookupField[0].entityType; //return entity logical name
var name = lookupField[0].name; //returns name of record
}
}
Published on:
Learn moreWe can help you with JavaScript - GetValue for different datatypes
If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.
Related posts
🚀 CRM ↔ ERP Real-Time Integration Framework
🚀 CRM ↔ ERP Real-Time Integration FrameworkSharing a simple and reliable pattern to implement bi-directional synchronization between Mi...
Security Model of Dynamics CRM
Business Unit – It is a way to group business activities.When an organization is created, a Root Business Unit is created by default. Thi...
Power Automate - [Dataverse]
Power Automate is used to automate operations through triggers and actions.Triggers: Added, Modified, Deleted, Manual (Instant), ScheduledActi...
Bulk insert CRM Data into SQL table using sqlbulkcopy
If you're in need of bulk inserting CRM data into a SQL table, this tutorial provides a step-by-step guide that will get you there with minima...
Most Used Plugin Syntax in Dynamics 365 CRM
For Dynamics 365 CRM users, plugins are essential tools that allow for the customization of business rules and processes. This tutorial delves...
Get option-set value from text and get option-set text from Value using plugin
If you're looking for a way to extract option-set values from text or vice versa, this plugin tutorial is just what you need. By following the...