Dynamics CRM 2013: Using OOB JScript functions

I always wondered if there is a way to leverage OOB (Out Of the Box) CRM JScript functions. If I can, this will save me a lot of time from rewriting these functions to execute my business logic. I’m happy to share with you the result of my finding, not sure if this is supported, so use at own risk.

What I had to do was register the Type.registerNamespace(“Mscrm”); namespace in my JScript file and then I was able to start taking advantages of the OOB JScript functions.

In this example I’m refreshing a CRM grid using the OOB function:

//Script Example
Type.registerNamespace(“Mscrm”); //CRM Namespace
calculatePointsSelectedOnClick = function(gridControl,entityTypeCode,selectedRecords){
Mscrm.RibbonActions.refreshGrid(gridControl); //Out the box CRM function

This means that I can be able to leverage the OOB CRM functions, will keep updating this post as I use/discover more functions.

Dynamics CRM 2013: Update record using Jscript

//Updating CRM records from Jscript
updateInvoice = function(invoiceGuid){
var invoice = {};
invoice.Description = “Updated from Jscript!!”;

updateCRMRecord = function (id, object, type) {
var req = new XMLHttpRequest();
req.open(“POST”, encodeURI(Xrm.Page.context.getServerUrl() + “/XrmServices/2011/organizationData.svc/” + type + “Set(guid’” + id + “‘)”), true);
req.setRequestHeader(“Accept”, “application/json”);
req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8″);
req.setRequestHeader(“X-HTTP-Method”, “MERGE”);
req.onreadystatechange = function () {
if (req.readyState == 4) {
req.onreadystatechange = null;
if (req.status == 204 || req.status == 1223) {


successCallback = function(){
//Do something