Notifications
Announcements
No record found.
When working with Dynamics 365, different field types handle different kinds of data, each with its specific requirements. The xrm-ex library simplifies interactions with these fields by offering a consistent approach to setting and getting values, regardless of field type. This guide will help you understand the unique characteristics of each field type, the data they store, and how to manipulate them using xrm-ex.
xrm-ex
Text fields in Dynamics 365 are straightforward, storing string data such as names, addresses, or any other textual information. With xrm-ex, you can easily set and get text values.
Example of Setting and Getting Text Fields
Here’s a look at how xrm-ex makes text field manipulation easy:
// Setting the value using the Value propertyfields.Firstname.Value = "John";// Setting the value using the setValue methodfields.Firstname.setValue("John");// Retrieving the value using the Value propertyvar firstname = fields.Firstname.Value; // Returns "John"// Retrieving the value using the getValue methodvar firstname = fields.Firstname.getValue(); // Returns "John"
The Value property in xrm-ex is unique to the library, allowing a more streamlined approach than the traditional setValue/getValue methods.
Value
setValue
getValue
Example of Working with Date Fields
Boolean fields store true or false values, commonly used for flags, switches, or options (e.g., Do Not Email).
true
false
Example of Boolean Fields
// Setting a Boolean valuefields.DoNotEmail.Value = true;// Getting a Boolean valuevar doNotEmail = fields.DoNotEmail.Value; // Returns true
To clear a field's current value, you can simply set it to null. This applies to all supported field types, allowing you to reset fields without additional code.
null
Example of Clearing Field Values
The main distinctions across field types lie in the kind of data they store and how that data is represented:
Date
The xrm-ex library helps unify field handling across various data types in Dynamics 365, whether you’re working with text, numbers, dates, or Booleans. Understanding the nuances of each field type ensures that you store data correctly and leverage the strengths of xrm-ex fully.