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 thisDo this
Get the executionContextUse the Pass execution context as first parameter option in the Handler Properties dialog
Get the formContextvar formContext = executionContext.getFormContext();
Get the Attribute Valuevar lastName = formContext.getAttribute("lastname").getValue();
Get the Id of the Current Data Recordvar id = formContext.data.entity.getId();
Get the Form Typevar formType = formContext.ui.getFormType();0Undefined1Create2Update3Read-Only4Disabled5Bulk Edit
Set notificationformContext.ui.setFormNotification('This is a message', 'LEVEL', 'NOTIFICATION_ID');Levels: ERROR, WARNING, INFO
Get Controlvar firstName = formContext.getControl("firstname");
Set the field as Read-onlyformContext.getAttribute("firstname").setDisabled(true);
Get Current User Idvar userGuid = formContext.context.getUserId();
Clear notificationformContext.ui.clearFormNotification('NOTIFICATION_ID');
Save the recordformContext.data.save(saveOptions).then(successCallback, errorCallback);formContext.data.save();Everything is optional. Documentation on MSDN.