CRM, JavaScript

Some helpful CRM 2016 Bookmarklets

I’ve been working in CRM Online (2016) a little for the past few weeks and I found these little bookmarklets to be helpful.

For those that don’t know, a bookmarklet is a snippet of JavaScript that can be saved as a Bookmark in Chrome, IE or Firefox. By prefixing your JavaScript function with javascript: you’re telling the browser to execute JavaScript rather than go to a particular URL

So far I have bookmarklets to

  • Print the current entity’s schema name
  • Print the current entity’s ID
  • Reopen the current entity’s form

The Print ones are quite nice because I used CRM’s in-built notification system.

Print Entity Schema Name as a CRM Notification

javascript:(
    function () 
    {
        for (var i=0; i<window.frames.length; i++) 
        {
            if (window.frames[i].Xrm && window.frames[i].Xrm.Page.data) 
            {
                var myXrm = window.frames[i].Xrm;
                var entitySchema = myXrm.Page.data.entity.getEntityName();
                var entityId = myXrm.Page.data.entity.getId();
                Xrm.Utility.openEntityForm(entitySchema, entityId); 
                break; 
            } 
        } 
    } 
)();

Print Entity ID as CRM Notification

javascript:(
    function () 
    {
        for (var i=0; i<window.frames.length; i++) 
        {
            if (window.frames[i].Xrm && window.frames[i].Xrm.Page.data) 
            {
                var myXrm = window.frames[i].Xrm;
                myXrm.Page.ui.setFormNotification("Entity ID: " + myXrm.Page.data.entity.getId(), "INFO");
                break; 
            } 
        } 
    } 
)();

Reopen the Entity form (hitting F5 sometimes takes me back to CRM home page)

javascript:(
    function () 
    {
        for (var i=0; i<window.frames.length; i++) 
        {
            if (window.frames[i].Xrm && window.frames[i].Xrm.Page.data) 
            {
                var myXrm = window.frames[i].Xrm;
                var entitySchema = myXrm.Page.data.entity.getEntityName();
                var entityId = myXrm.Page.data.entity.getId();
                Xrm.Utility.openEntityForm(entitySchema, entityId); 
                break; 
            } 
        } 
    } 
)();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s