CRM 2013 Custom Bookmarklets to Replace Missing Save Buttons

Posted: July 23, 2014 in Dynamics CRM 2013, JavaScript

In a previous blog post by Jared Johnson, he showed how to create some custom browser bookmarks/favourites to help make some common tasks easier in 2013. These included easily copying the ID of a record, and quickly refreshing the data on the form if it has changed by a workflow etc. He also explained how to get the current active iframe so that we can access all of the forms Xrm.Page functions.

In my next few blog posts I’m going to explore some of the other possibilities available to us with custom bookmarkets, starting with how to restore the Save, Save & Close, and Save & New buttons so that they’re always available to us.

So often I find myself pointing into the top left corner to save my changes, and then remember that I need to go into the opposite corner, or just navigate away. I idea of these bookmarklets is that my new custom bookmarks will sit at the start of my bookmarks bar, so that when I go reaching for that save button, I just have to go a little further to get it. Another added benefit is that we can bring back the Save & New button, which has been removed entirely from CRM 2013, making it difficult to create multiple related records from a parent while maintaining the mappings.

To add these 3 custom bookmarklets, simply create some new bookmarks, and set the URL’s to use the following scripts:

Save:

javascript:$("iframe").filter(function () { return ($(this).css('visibility') == 'visible') })[0].contentWindow.Xrm.Page.data.entity.save();

 

Save & Close:

javascript:$("iframe").filter(function () { return ($(this).css('visibility') == 'visible') })[0].contentWindow.Xrm.Page.data.entity.save('saveandclose');

 

Save & New:

javascript:$("iframe").filter(function () { return ($(this).css('visibility') == 'visible') })[0].contentWindow.Xrm.Page.data.entity.save('saveandnew');

 

Whenever we are on a record now, whether it’s new or existing, we can use these buttons. The buttons will of course show up whether you’re on a form or not, however it also means you can use these buttons in any CRM 2013 system; so for someone like me, who needs to use several CRM environments at once, this definitely comes in handy.

Since we have access to all the functions of Xrm.Page, the possibilities really are endless as to what we can do with these bookmarklets. In my next few blog posts I’ll go through some other useful buttons we can add to build up our own custom command bar.

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