PreWinOpportunity.cs
if (context.InputParameters.Contains("OpportunityClose") && context.InputParameters["OpportunityClose"] is Entity) { #region Throw Exception For Test //throw new InvalidPluginExecutionException("PreWinOpportunity - OpportunityCloseWon"); #endregion var entity = (Entity)context.InputParameters["OpportunityClose"]; if (entity.Attributes.Contains("opportunityid")) { var opportunityId = ((EntityReference)entity.Attributes["opportunityid"]).Id; var serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); // Getting the service from the Organisation Service. IOrganizationService crmService = serviceFactory.CreateOrganizationService(context.UserId); Entity opportunity = crmService.Retrieve("opportunity", opportunityId, new ColumnSet(new string[] { "description" })); if (!opportunity.Contains("description")) { throw new InvalidPluginExecutionException("You must provide a value for description."); } else { //throw new InvalidPluginExecutionException("none"); } } else { throw new InvalidPluginExecutionException("none:opportunityid"); } } else { throw new InvalidPluginExecutionException("none:PreWinOpportunity - OpportunityCloseWon"); } }
PluginRegistration.exe
沒有留言:
張貼留言