Walkthrough: Capturing the GUID Values of Records Selected in a Grid (CRM 2011 Edition) 桃扇骨 2021-09-30 07:50 148阅读 0赞 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)][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)][Url_ _RibbonDiffXml] a **Name** attribute is required. When the **CrmParameter** is a child of the [<JavaScriptFunction> (RibbonDiffXml)][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][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][here 1]. 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 [here]: http://msdn.microsoft.com/en-us/library/cc150860.aspx [CrmParameter_ _RibbonDiffXml]: http://msdn.microsoft.com/en-us/library/gg309332.aspx [Url_ _RibbonDiffXml]: http://msdn.microsoft.com/en-us/library/gg328363.aspx [JavaScriptFunction_ _RibbonDiffXml]: http://msdn.microsoft.com/en-us/library/gg334432.aspx [Web Page _HTML_ Web Resources]: http://msdn.microsoft.com/en-us/library/gg309536.aspx [here 1]: http://msdn.microsoft.com/en-us/library/gg327945.aspx
还没有评论,来说两句吧...