Показать сообщение отдельно
Старый 13.11.2009, 21:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
CRM Programmer: Passing parameters between MS CRM plugins
Источник: http://crmpro.blogspot.com/2009/11/p...en-ms-crm.html
==============

I was needed to pass a variable from one plugin to another. If you have a two plugin at pre and post stage registered for on entity, then you can use a SharedVariables context property. But, if every plugins is a different assembly, and they are registered for a different entities... So, when the first plugin is firing, the second, which is starting after that, needed to know some information for redirecting it logic to another way.

I had created some common assembly with helper methods and called it "Helper". Then I had created a static class with static variable and had put the value into it, at the first plugin execution runtime. In the second plugin I just get the value from the static common variable.

And nothing about read\write DB operations.
Helper assembly.
namespace Helper
{
public static class Keeper
{
private static bool _UpdateOppAfterHistory = true;
public static bool UpdateOppAfterHistory
{
get { return _UpdateOppAfterHistory; }
set { _UpdateOppAfterHistory = value; }
}

}
public class OpportunityHelper
{ ... }
}

First firing plugin code
Keeper.UpdateOppAfterHistory = false;

OpportunityHelper.CreateOpportunityHistory(Opp,crmService);

// removing the flag to the back
Keeper.UpdateOppAfterHistory = true;

Second firing plugin code
// common shared variable analysis
bool UpdateOppAfterHistory = Keeper.UpdateOppAfterHistory;
if (UpdateOppAfterHistory)
{ ... }



Источник: http://crmpro.blogspot.com/2009/11/p...en-ms-crm.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.