Problem SOLVED by using localContext.SharedVariables in the plugin. First you need a function to check if the SharedVariables exist before executing your plugin logic, if it does not exist then add it. The trick is to check the SharedVariables in the parent context of the context. See below code:
protected void ExecutePostCaseUpdate(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
if (!CheckRecursionIndicator(localContext.PluginExecutionContext, "ExecutePostCaseUpdateIndicator")) return;
var updateCase = ((Entity)localContext.PluginExecutionContext.InputParameters["Target"]).ToEntity();
// TODO: Implement your custom Plug-in business logic.
updateCase.Title = "Plugin Shared Viarable Test";
localContext.OrganizationService.Update(updateCase);
}
///
/// Check plugin loop recursion
///
/////////
private bool CheckRecursionIndicator(IPluginExecutionContext context, string recursionIndicator)
{
if (!context.SharedVariables.Contains(recursionIndicator))
{
while (context.ParentContext != null)
{
if (context.ParentContext.SharedVariables.Contains(recursionIndicator))
{
return false;
}
context = context.ParentContext;
}
}
context.SharedVariables.Add(recursionIndicator, (Object)true);
return true;
}
*This post is locked for comments

Report
All responses (