Download the Ribbon XML from CRM using solution.
In the command definition of the button, pass the custom CRM parameter value to javascript function as
"SelectedControl". This will give you the below details of selected record in the Grid,
1. Id (Guid)
2. TypeCode
3. TypeName (Schema Name of entity)
4. Name (what you were looking for)
Here is the example of the XML snippent for a button,
*******************************************************************************
<CommandDefinition Id="abcd_grid.Commands.PublishRecords">
<EnableRules>
<EnableRule Id="abcd_grid.TestEnableRules.True" />
</EnableRules>
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="ProcessSelectedRecord" Library="$webresource:abcd_/scripts/abcd.forms.js">
<CrmParameter Value="SelectedControl" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
*******************************************************************************
Here is the javascript function which accepts the parameter and gets the required details of a account record.
function ProcessSelectedRecord(parameterFromXML)
{
var records = parameterFromXML.get_selectedRecords();
if(records.length>0) // you can run for each loop
{
var accountid = records[0].Id // Guid of selected record in the grid - {8BAD1963-0134-E711-811B-0050568268BF}
var typeCode = records[0].TypeCode // Entity Type Code - 1
var entityName = records[0].TypeName // Entity Schema Name - account
var accountName = records[0].Name // Account Name - Sample Account
}
}
*******************************************************************************
Hope this helps.
Jai CRM
Cheers Buddy!
Thank you!
Suraj