Sonoma Partners Microsoft CRM and Salesforce Blog

JavaScript Bookmark Series – Part 1

Today we’ll be kicking off a series of posts about JavaScript bookmarks that can be useful to CRM developers and customizers.  These bookmarks are easy to setup and could help save some time.  To create these bookmarks, just browse to any CRM page and add it to your favorites (This will get you the lovely CRM logo).  Then, you can edit the bookmark and set the URL to the JavaScript mentioned in the post.


The first bookmark in the series will alert any fields that are dirty on a CRM form.  As a developer, you’ll know that sometimes forms become perpetually dirty due to some custom JavaScript that is manipulating a field value automatically.  This makes the pesky “Are you sure you want to leave this page?” alert show up when the user closes the form even if they didn’t change a value.

To easily debug this issue, make a bookmark setting the URL to the following:

javascript:var message="The following fields are dirty: \n";window.frames[0],index){if(attribute.getIsDirty()==true){message+="\u2219 "+attribute.getName()+"\n";}});alert(message);

Now browse to the ‘dirty’ CRM form and click your new bookmark.  This should alert the names of all the fields that are dirty.

That concludes our first bookmark of the series!  Let us know in the comments if you have any suggestions for a useful bookmark.

Topics: Microsoft Dynamics CRM 2011 Microsoft Dynamics CRM Online