Showing posts with label Bulk Edit. Show all posts
Showing posts with label Bulk Edit. Show all posts

Sunday, July 29, 2012

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

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<records.lenght;i++)
 {
   alert(records[i]);
 }
}

Hope this helps and is useful!!

Tuesday, October 18, 2011

Enable Scripts on Bulk Edit form in CRM 2011

CRM 2011 includes the feature to enable script on the bulk edit form. By default the scripts are disabled for bulk edit forms.

To enable the script for Bulk edit forms check the below syntax

<event
active=["0" "1" "true" "false"]
application=["0" "1" "true" "false"]
attribute="String"
BehaviorInBulkEditForm="String"
eventType=["DataEvent" "ControlEvent"]
name="String">
<dependencies />
<Handlers />
<InternalHandlers />
</event>

See below detailed descriptions for the attributes.




Steps to enable the script on bulk edit form:
- Include the entity for which you would like to enable the bulk edit script and export the solution.
- Open the customization.xml
- Add BehaviorInBulkEditForm="Enabled" to the event handlers as shown below


<event name="onload" application="false" active="false" BehaviorInBulkEditForm="Enabled" >
<event name="onsave" application="false" active="false" BehaviorInBulkEditForm="Enabled" >

- Save and Import the solution, publish it.
- Now your script will work on bulk edit form.

This way you can let your users use bulk edit freely with your custom script also executing just fine. Earlier, usually if there was custom business logic to be performed plugins were advised as it would allow the custom business logic to be executed for all records that were edited through Bulk Edit.

Wednesday, August 26, 2009

How to Bulk Edit Attributes that show up Disabled on the Bulk Edit Form

We came across this really tricky situation and we would like to thank Microsoft for having a KB article (http://support.microsoft.com/kb/949941) for this.

We wanted to bulk edit a few of the accounts using the Actions => Edit option. The form that comes up here displays all attributes available for the Account entity. You would however notice that some of them are disabled though. Since we had 2 custom picklist type of attributes, one showing up as enabled the other disabled, it was easy to identify the possible reasons for disabling this one had custom code written on its onchange event while the other did not.

But we still wanted to be able to Bulk Edit this attribute without having the need to create a custom page just for editing a custom picklist attribute. Our search lead to the following KB article that explains the steps to enable this.

To have this explained in short, the entity customization file has a property “BehaviourInBulkEditForm” for the event tags. This determines the behavior of the attribute and the code written on the event. The valid values are

Enabled -- If you use this value, the field is enabled. Additionally, the code for the event is run when the event is called.
Disabled -- If you use this value, the field is disabled.
EnabledButNoRender -- If you use this value, the field is enabled. However, the code for the event is not run when the event is called.

Exporting the customization and making the below change should enable the attribute and not have the code written on the onchange event fired

<event name="setadditionalparams" application="true" active="true" behaviorinbulkeditform="EnabledButNoRender">