其他分享
首页 > 其他分享> > Walkthrough: Capturing the GUID Values of Records Selected in a Grid (CRM 2011 Edition)

Walkthrough: Capturing the GUID Values of Records Selected in a Grid (CRM 2011 Edition)

作者:互联网

原文链接:http://www.cnblogs.com/Republic/archive/2011/08/25/2153663.html

You might remember this one from the SDK for CRM 4.0. Doing the same steps as described here won’t get you there for CRM 2011. It seems the dialogArguments no longer contain the selected Guids.

It took me a while to figure this out since there was no entry explaining this in the CRM 2011 SDK. Putting it all together got me there finally.

It all starts of course by adding a new ribbon button to the corresponding grid you would like to get the selected items from. I won’t get into details here on how to do that.
Once you have the button and command definitions in place, it might look something like this:

<CommandDefinition Id="NORRIQ.nrq_customentity.Grid.ButtonProcess">
<EnableRules>
<EnableRule Id="Mscrm.Enabled" />
</EnableRules>
<DisplayRules />
<Actions>
<Url Address ="$webresource:nrq_/ProcessCustomEntity.htm" WinMode="1" WinParams="dialogWidth:400px;dialogHeight:200px" >
<CrmParameter Name="data" Value="SelectedControlSelectedItemIds" />
</Url></Actions>
 </CommandDefinition>

  

You should especially take a look at the CrmParameter element of the XML. When adding an action of type URL, any parameter you pass should be called data.

This is not really mentioned in the SDK under the <CrmParameter> (RibbonDiffXml) section. It does state here that you should call it data, as I can expect you would also want to call external URL’s.

When the CrmParameter is a child of the <Url> (RibbonDiffXml) a Name attribute is required. When the CrmParameter is a child of the <JavaScriptFunction> (RibbonDiffXml) element, the Name attribute is not valid.

Looking a bit further in the SDK you will end up in the Web Page (HTML) Web Resources section which then states that a Web Page resource can only accept and additional parameter called data. For more info check here.

After figuring this out I was sure to get the SelectedControlSelectedItemIds parameter passed to my web page in the data parameter.

You can now break down this data parameter in your web page with a simple JavaScript function like the following:

function GetSelectedIds() {
var vals = new Array();
if (location.search != "") {
vals = decodeURIComponent(location.search).split("=");
var selectedIds = vals[1].toString().split(',');
}
}

  If you were using a JavaScript action the solution would be allot simpler. You could just define your JavaScript function to accept a parameter. This parameter will then be filled by your CrmParameter with the SelectedControlSelectedItemIds. No need to define a name here and you could also add multiple CrmParameters J

转载于:https://www.cnblogs.com/Republic/archive/2011/08/25/2153663.html

标签:Walkthrough,parameter,Selected,here,data,Records,get,2011,CRM
来源: https://blog.csdn.net/weixin_30340745/article/details/97570600