Sep 27, 2012

Read Selected Guids from Subgrid

Through the article I posted about a custom recalculation button, I explained the way of introducing a custom buttons to the ribbon. Check it here.

When it comes to the subrid, most important requirement is to read the selected Ids. We will see how we pass those in to a Java script through the custom button.

This is the simple way we need to pass selected Ids as a parameter for the calling method. (Read the previous article if you need entire entry for custom button)

....
<Actions>
<JavaScriptFunction 
  Library="$webresource:new_createquote.js" 
  FunctionName="CreateQuote">
<CrmParameter Value="SelectedControlSelectedItemIds"></CrmParameter>
</JavaScriptFunction>
</Actions>
....

Will see how those Ids are grasped from the method.

function CreateQuote(value)
{
    alert(value);
}

Below is the result which shows the selected ids as an array.



Quite simple, yet important.

Note:
There are few more parameter types we can pass to JavaScript methods from ribbon as required. Please check them below;
  • SelectedEntityTypeCode : A number representing the unique type of entity for a record selected in a grid. The Entity type code will vary between deployments.
  • SelectedEntityTypeName : A string representing the unique name of the entity for a record selected in a grid.
  • FirstSelectedItemId : Provides one GUID identifier as a string for the first item selected in a grid.
  • SelectedControlSelectedItemCount : The number of selected items in a grid.
  • SelectedControlSelectedItemIds : A string array of GUID Id values for all selected items in a grid.
  • SelectedControlAllItemCount : A string array of GUID Id values for all selected items in a grid.
  • SelectedControlAllItemIds : A string array providing the GUID Id values for all items displayed in a grid.
  • SelectedControlUnselectedItemCount : The number of unselected items in a grid.
  • SelectedControlUnselectedItemIds : A string array of GUID Id values for all unselected items in a grid.
Read more information about CRM CrmParameter type here.

No comments:

Post a Comment