Dynamics 365 – Different Ways of Showing Form Level Error Messages – setFormNotification | setIsValid

Form notifications are useful when you want to prevent the user saving the form if the form fields do not meet the conditions. Say you have 2 date fields called "Start Date" and "End Date". You want the records can only be saved if the "End Date" is bigger than the "Start Date". You have … Continue reading Dynamics 365 – Different Ways of Showing Form Level Error Messages – setFormNotification | setIsValid

Dynamics 365 – How to get and use formContext

The formContext is a part of executionContext and it replaces deprecated Xrm.Page starting from Version 9. Xrm.Page object was used to represent a form or an item on the form. With the latest version, the Xrm.Page object is deprecated, and you should use the getFormContext method of the passed in execution context object to return reference to the appropriate form or … Continue reading Dynamics 365 – How to get and use formContext

Dynamics 365 – How to Trigger OnChange Event of an Attribute

fireOnChange() function is used to trigger the registered onChange events of an attribute. It is also very useful when you update an attribute through Javascript Code and it onChange event doesn't trigger. When you update an attribute from Javascript code, its onChange event doesn't trigger. If you want it to be triggered, you have to … Continue reading Dynamics 365 – How to Trigger OnChange Event of an Attribute

Dynamics 365 Updating Readonly Field – setSubmitMode()

To update readonly fields with Javascript simply use setSubmitMode() after setValue() function. always: The data is always sent with a save. never: The data is never sent with a save. When this value is used, the column(s) in the form for this column cannot be edited. dirty: Default behavior. The data is sent with the … Continue reading Dynamics 365 Updating Readonly Field – setSubmitMode()

Dynamics 365 Web Api – How to Set Lookup Field Value

When updating lookup values, or using lookups in entities you must use the @odata.bind annotation to set the value. The syntax for this is: {field_name@odata.bind: "/entitypluralname(guid)"} Some examples: ownerid@odata.bind:"/systemusers(a30cbf7b-69cd-4299-b468-b4978f716af7)"opportunityid@odata.bind: "/opportunities(a30cbf7b-69cd-4299-b468-b4978f716af7)" For lookups that have different possible entity types(i.e regardingobjectid), this changes slightly (note the entity logical name at the end of the "name") parentcustomerid_account@odata.bind = … Continue reading Dynamics 365 Web Api – How to Set Lookup Field Value

Dynamics 365 – Make the Form Readonly with Javascript

To make the form read-only in Dynamics 365 you have 2 options. Either changing record status to Inactive or making all form fields disabled with Javascript. Changing record status to Inactive might not suitable for some business cases. For example you might want to make your form read-only based on an attribute. If you change … Continue reading Dynamics 365 – Make the Form Readonly with Javascript

Dynamics 365 – Execute Custom Action From Javascript with Input and Output Parameters

In Dynamics 365, you can call an action directly from JavaScript with its inputs. This can be achieved using the WebAPI. First, let’s create a new custom action in Dynamics 365. Our action will accept RecordURL, Prefix, FieldsToIgnore parameters. Then it will create a copy of the Record by querying its metadata. RecordURL – Input stringPrefix– … Continue reading Dynamics 365 – Execute Custom Action From Javascript with Input and Output Parameters