Loading...

JavaScript - GetValue for different datatypes

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 more
Need help with this product?

We 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.

Microsoft Dynamics CRM
Microsoft Dynamics CRM

Share post:

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...

9 months ago

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...

11 months ago

Power Automate - [Dataverse]

Power Automate is used to automate operations through triggers and actions.Triggers: Added, Modified, Deleted, Manual (Instant), ScheduledActi...

11 months ago

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...

3 years ago

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...

3 years ago

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...

3 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.