xrm toolkit code example
Example: crm toolbox webresources manager intellisense
var Sdk = window.Sdk || {};
(function () {
var myUniqueId = "_myUniqueId";
var currentUserName = Xrm.Utility.getGlobalContext().userSettings.userName;
var message = currentUserName + ": Your JavaScript code in action!";
this.formOnLoad = function (executionContext) {
var formContext = executionContext.getFormContext();
formContext.ui.setFormNotification(message, "INFO", myUniqueId);
window.setTimeout(function () { formContext.ui.clearFormNotification(myUniqueId); }, 5000);
}
this.attributeOnChange = function (executionContext) {
var formContext = executionContext.getFormContext();
var accountName = formContext.getAttribute("name").getValue();
if (accountName.toLowerCase().search("contoso") != -1) {
formContext.getAttribute("websiteurl").setValue("https://www.contoso.com");
formContext.getAttribute("telephone1").setValue("425-555-0100");
formContext.getAttribute("description").setValue("Website URL, Phone and Description set using custom script.");
}
}
this.formOnSave = function () {
Xrm.Navigation.openAlertDialog({ text: "Record saved." });
}
}).call(Sdk);