MS Dynamics 365: Some useful JavaScript Functions
Hey there! Finally, the time has come to pay some additional attention to this site. Soo, after almost a year, let's do another quick post which is hopefully sure to be only one of many. Dive head-first, so to say. We'll try to catch our breath later. Let's do it.
We'll start with some useful JavaScript functions that you'll need in your adventures with MS Dynamics 365 Development. A quick cheat-sheet, if you will. It is for CRM v9.
To do this | Do this | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Get the executionContext | Use the Pass execution context as first parameter option in the Handler Properties dialog | ||||||||||||
Get the formContext | var formContext = executionContext.getFormContext(); |
||||||||||||
Get the Attribute Value | var lastName = formContext.getAttribute("lastname").getValue(); |
||||||||||||
Get the Id of the Current Data Record | var id = formContext.data.entity.getId(); |
||||||||||||
Get the Form Type | var formType = formContext.ui.getFormType();
|
||||||||||||
Set notification | formContext.ui.setFormNotification('This is a message', 'LEVEL', 'NOTIFICATION_ID');
Levels: ERROR, WARNING, INFO |
||||||||||||
Get Control | var firstName = formContext.getControl("firstname"); |
||||||||||||
Set the field as Read-only | formContext.getAttribute("firstname").setDisabled(true); |
||||||||||||
Get Current User Id | var userGuid = formContext.context.getUserId(); |
||||||||||||
Clear notification | formContext.ui.clearFormNotification('NOTIFICATION_ID'); |
||||||||||||
Save the record | formContext.data.save(saveOptions).then(successCallback, errorCallback); formContext.data.save();
Everything is optional. Documentation on MSDN. |
Comments
Logged in users can add comments.
LoginLeave a new Comment