Sunday, December 9, 2012

Quick way to get the ID(GUID) of record, Dirty Fields in the form and Scema names displayed for each fields in MS CRM 2011

ID(GUID) of Record
the below link really give an awesome way to fetch the ID(GUID) of a record which we mostly need, for any unit testing or other requirements...

http://blog.sonomapartners.com/2012/08/javascript-bookmark-series-part-2.html
script for this is

javascript: var id = frames[0].Xrm.Page.data.entity.getId(); if (id) { clipboardData.setData("Text", id.toString()); alert(id); } else { alert('No id yet!'); }

 Dirty Fields in MS CRM Form
 
use this idea how to fetch the dirty fields(fields that has been changed in the form) from MS CRM form...
script is as below
javascript:var message="The following fields are dirty: \n";window.frames[0].Xrm.Page.data.entity.attributes.forEach(function(attribute,index){if(attribute.getIsDirty()==true){message+="\u2219 "+attribute.getName()+"\n";}});alert(message);
 Get Schema Names use the below link to get the way to find the schema names of the fileds on the form..
script is as below
javascript:frames[0].Xrm.Page.ui.controls.forEach(function(a){a.setLabel(a.getName())});
 how to put in Favorite bar and use it...
just browse to any of the crm pages...
then click Favorites -> Add to Favorite
now go to Favorite and the saved one and right click and then properties...
then in the URL , update the above JS code for diff requirements... and save
 
then when u need this requirement, open the record, then do ctrl + N (to get the Fav bar), then click the item... and it will prompt you the result...
then just click on that aleart window and do ctrl + C(copy command), then paste in notepad to get the result...
 
thats it...
:)

 

No comments:

Post a Comment