Mscrm 2011 plugin syntax on opportunity lose message:
public void CloseAssociatedOpportunity(IPluginExecutionContext context, IOrganizationService service)
{
if (context.InputParameters.Contains("EntityMoniker") &&
context.InputParameters["EntityMoniker"] is EntityReference
&& context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity)
{
List<Guid> opportunityIds = new List<Guid>();
EntityReference entity = (EntityReference)context.InputParameters["EntityMoniker"];
OptionSetValue state = (OptionSetValue)context.InputParameters["State"];
OptionSetValue status = (OptionSetValue)context.InputParameters["Status"];
//state 1 = Inactivate : state 0 = Activate
if (entity.LogicalName == "tls_joborder" && state.Value == 1)
{
//Fecth the associated Opportunities of the Job Order
opportunityIds = GetOpportunitiesIds(service, entity.Id);
// Fetching Opportunity selected in the Lookup
if(context.PostEntityImages["PostImage"].Contains("tls_opportunity")
&& !String.IsNullOrEmpty(((EntityReference)context.PostEntityImages["PostImage"].Attributes["tls_opportunity"]).Id.ToString()))
opportunityIds.Add(((EntityReference)context.PostEntityImages["PostImage"].Attributes["tls_opportunity"]).Id);
if (opportunityIds.Count > 0)
{
foreach (Guid opprtunityId in opportunityIds)
{
CloseOpportunitiesAsLost(service, opprtunityId);
}
}
}
}
}
public void CloseAssociatedOpportunity(IPluginExecutionContext context, IOrganizationService service)
{
if (context.InputParameters.Contains("EntityMoniker") &&
context.InputParameters["EntityMoniker"] is EntityReference
&& context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity)
{
List<Guid> opportunityIds = new List<Guid>();
EntityReference entity = (EntityReference)context.InputParameters["EntityMoniker"];
OptionSetValue state = (OptionSetValue)context.InputParameters["State"];
OptionSetValue status = (OptionSetValue)context.InputParameters["Status"];
//state 1 = Inactivate : state 0 = Activate
if (entity.LogicalName == "tls_joborder" && state.Value == 1)
{
//Fecth the associated Opportunities of the Job Order
opportunityIds = GetOpportunitiesIds(service, entity.Id);
// Fetching Opportunity selected in the Lookup
if(context.PostEntityImages["PostImage"].Contains("tls_opportunity")
&& !String.IsNullOrEmpty(((EntityReference)context.PostEntityImages["PostImage"].Attributes["tls_opportunity"]).Id.ToString()))
opportunityIds.Add(((EntityReference)context.PostEntityImages["PostImage"].Attributes["tls_opportunity"]).Id);
if (opportunityIds.Count > 0)
{
foreach (Guid opprtunityId in opportunityIds)
{
CloseOpportunitiesAsLost(service, opprtunityId);
}
}
}
}
}
No comments:
Post a Comment