How to get all the selected records id for the bulk edit form

By | July 30, 2012
Further to one of our previous blog spot

We can write scripts on bulk edit form to check that the entered field value is unique for the selected group of records. If the value is duplicate then the user should get an alert and the bulk edit form should be closed.

To achieve this, we need to retrieve all the records and compare the new value with the existing values.

But to retrieve we require the ids of all the selected records for bulk edit. To get ID we normally use

Xrm.Page.data.entity.getId()

But this will not give us the id of all the selected records. To get ids of all selected records we need to use a window command window.dialogArguments.

 //check whether the form is bulk edit form

 var formType = Xrm.Page.ui.getFormType();

if (formType == 6)
{

 //Read ids from dialog arguments

 var records = window.dialogArguments;

 for(i=0; i {
   alert(records[i]);
 }
}

Hope this helps and is useful!!