entity

This object helps us work with the current entity record; for example, accessing entity properties. The following methods are available under this object:

addOnSave We can use this method to call our specific function on saving the entity form. We can use this method as follows:
formContext.data.entity.addOnSave(accountOnSave)
getDataXml We can use this method to find out which field is updated on an entity form. This method provides us with an XML string where we can see the field that will be saved to the Dynamics 365 CE database:
formContext.data.entity.getDataXml();
getEntityName If we want to know the logical name of the current entity using client-side code, we can use this method. For example, if we use the following code in our vehicle entity, it will return him_vehicle:
formContext.data.entity.getEntityName()
getEntityReference We can use this method to get a lookup reference. We can use it in the following code:
formContext.data.entity.getEntityReference();
This method returns an object that contains the following three properties:
  • entityType: The logical name of the entity
  • id: The GUID of the entity record
  • name: The primary field value of the entity
getId This method can be used to get the GUID of the current record:
formContext.data.entity.getId();
getIsDirty If we want to know whether any field values have changed in the form or not, we can use this method. We can use the following code:
formContext.data.entity.getIsDirty();
getPrimaryAttributeValue As we know, every entity has one primary field of text type. If we want to get the value of the primary field, we can use the following code:
formContext.data.entity.getPrimaryAttributeValue();
isValid This method can be used to find out whether all the entity field data is valid:
formContext.data.entity.isValid();
removeOnSave If we want to remove a function on saving the entity form, we can use the following code:
formContext.data.entity.removeOnSave(accountOnSave);
save This method is used to save an entity record. We have a different parameter for the save method, where we can define whether we want to close the entity form or want to open a new entity form after saving:
formContext.data.entity.save(saveOption);
For example, if we want to open a new entity form after saving, we can use the following code:
formContext.data.entity.save("saveandnew");

 

We can use the preceding methods to interact with Dynamics 365 CE entities.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset