Skip to content

Instantly share code, notes, and snippets.

@gashupl
Created August 26, 2016 10:36
Show Gist options
  • Save gashupl/b294fdc6054e80897b7519ad1dee80e2 to your computer and use it in GitHub Desktop.
Save gashupl/b294fdc6054e80897b7519ad1dee80e2 to your computer and use it in GitHub Desktop.
Dynamics CRM script presenting TurboForms OnChange events behavior
function FormOnLoad(){
var eventHandler = function(executionContext){
alert(executionContext.getEventSource().getName());
}
var attributes = Xrm.Page.getAttribute();
attributes.forEach(function(element) {
element.addOnChange(eventHandler);
});
var accountRef = new Array();
accountRef[0] = new Object();
accountRef[0].id = "D84CFC52-8E3F-E611-8138-00155D7BE808";
accountRef[0].name = "Parent";
accountRef[0].entityType = "account";
Xrm.Page.getAttribute("new_text").setValue("Sample text");
Xrm.Page.getAttribute("new_optionset").setValue(100000001);
Xrm.Page.getAttribute("new_bool").setValue(true);
Xrm.Page.getAttribute("new_int").setValue(1);
Xrm.Page.getAttribute("new_float").setValue(1);
Xrm.Page.getAttribute("new_decimal").setValue(1);
Xrm.Page.getAttribute("new_money").setValue(1);
Xrm.Page.getAttribute("new_multilinetext").setValue("Sample text");
Xrm.Page.getAttribute("new_datetime").setValue(new Date());
Xrm.Page.getAttribute("new_accountid").setValue(accountRef);
Xrm.Page.getAttribute("new_customer").setValue(accountRef);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment