简体   繁体   English

在功能区中创建按钮以使用crm 2011中的插件更新实体

[英]create a button in ribbon for update a entity using a plugin in crm 2011

I create a solution in Dynamic CRM 2011 for sending SMS. 我在Dynamic CRM 2011中创建了一个用于发送SMS的解决方案。

in my solution i have 2 entity,the first one for sending SMS and the second one for save Send result. 在我的解决方案中,我有2个实体,第一个用于发送SMS,第二个用于保存发送结果。

I create plugin for second entity, plugin connect to web service and check the result of sending and update the entity, so the steps for update sending statue should be like below: 我为第二个实体创建了插件,插件连接到Web服务并检查了发送和更新实体的结果,因此更新发送状态的步骤应如下所示:

1- User select one or more entity and press a custom button in ribbon 1-用户选择一个或多个实体,然后按功能区中的自定义按钮

2- CRM run my plugin and connect to web service and update the result field 2- CRM运行我的插件并连接到Web服务并更新结果字段

so i create the plug in and create the button but i don't know how to run plugin(C# Code) when button hase been pressed. 所以我创建了插件并创建了按钮,但是当按钮被按下时我不知道如何运行插件(C#代码)。

if any one know this or have better solution for update SMS result, please tell me. 如果有人知道这一点或有更好的解决方案来更新SMS结果,请告诉我。

note: i register a Update step and a pre Image for plugin. 注意:我注册了一个Update步骤和一个用于插件的pre Image。

please help me. 请帮我。

Option 1 (no javascript or custom button): 选项1(无JavaScript或自定义按钮):

Create a Check Send Status checkbox on the SMS entity. SMS实体上创建一个Check Send Status复选框。 Move your plugin from the Send result entity to the Update of the SMS entity, and make it fire when Check Send Status is set to true. 将您的插件从“ Send result实体移动到“ SMS实体的Update ”,并在“ Check Send Status设置为true时触发它。 The plugin can now check the send status for the SMS and create the Send result entity with the appropriate result. 插件现在可以检查SMS的发送状态,并使用适当的结果创建Send result实体。

Your users can then use the multi-edit button. 然后,您的用户可以使用多重编辑按钮。 They can highlight multiple SMS records, click Edit and then set Check Send Status to true, which will fire your plugin. 他们可以突出显示多个SMS记录,单击“编辑”,然后将“ Check Send Status设置为true,这将触发您的插件。

Option 2 (custom javascript): 选项2(自定义javascript):

Write a javascript method for your button that will use the SelectedControlSelectedItemIds parameter. 为您的按钮编写一个JavaScript方法,该方法将使用SelectedControlSelectedItemIds参数。 See here for more information: http://social.microsoft.com/Forums/en-US/79f959ac-0846-472f-bff1-4f5afe692a56/getting-selected-records-guids-in-crm-2011?forum=crm 请参阅此处以获取更多信息: http : //social.microsoft.com/Forums/zh-CN/79f959ac-0846-472f-bff1-4f5afe692a56/getting-selected-records-guids-in-crm-2011?forum=crm

Your javascript method needs to loop through those IDs and then create the Send result record, which should fire your existing plugin (assuming it is on Create ). 您的javascript方法需要遍历这些ID,然后创建“ Send result记录,这将触发您现有的插件(假设它位于Create )。

You cannot directly call a plugin from a ribbon button (indirectly you could update the record which triggers the plugin) 您不能直接通过功能区按钮调用插件(间接地,您可以更新触发插件的记录)

The javascript options above are great options, but if you would like to work within managed code: 上面的javascript选项是不错的选择,但是如果您想在托管代码中工作:

Another option could be to connect the ribbon button to a workflow to calls a custom workflow activity that preforms whatever logic you need to preform. 另一个选择是将功能区按钮连接到工作流,以调用自定义工作流活动,该活动将执行您需要执行的逻辑。 This will prevent you from having to trigger a plugin and instead just call on on-demand workflow. 这将避免您不得不触发插件,而只是按需调用工作流。

Let me know if you need any assistance with how to do that. 让我知道您是否需要任何帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM