csharp CRM 2016 #Workflows#CRM2016 #MoussaElAnnan
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp CRM 2016 #Workflows#CRM2016 #MoussaElAnnan相关的知识,希望对你有一定的参考价值。
// Create the context
IWorkflowContext context = executionContext.GetExtension <IWorkflowContext> ();
_primaryEntity = context.PrimaryEntityId;
Guid processId = new Guid(GetProcessId(service, "workflow", “name”, "StateFlow").Id.ToString());
ExecuteWorkFlow(service, processId, _primaryEntity);
private void ExecuteWorkFlow(IOrganizationService service, Guid workFlowId, Guid entityId) {
try {
// Create an ExecuteWorkflow request.
ExecuteWorkflowRequest request = new ExecuteWorkflowRequest() {
WorkflowId = workFlowId, EntityId = entityId
};
// Execute the workflow.
ExecuteWorkflowResponse response = (ExecuteWorkflowResponse) service.Execute(request);
} catch (Exception ex) {
throw new InvalidPluginExecutionException();
}
}
private Entity GetProcessId(IOrganizationService service, string EntityLogicalName, string SearchFieldName, object SearchValue)
//Internal method used to search for entity records
{
EntityLogicalName = EntityLogicalName.ToLower();
SearchFieldName = SearchFieldName.ToLower();
QueryExpression query = new QueryExpression(EntityLogicalName);
query.ColumnSet = new ColumnSet(true);
query.Criteria.AddCondition(new ConditionExpression(SearchFieldName, ConditionOperator.Equal, SearchValue));
query.Criteria.AddCondition(new ConditionExpression("type", ConditionOperator.Equal, 1));
try {
EntityCollection response = service.RetrieveMultiple(query);
if (response != null && response.Entities.Count > 0)
return response.Entities[0];
else {
return null;
}
} catch (Exception ex) {
//Do error handling throw ex; }
}
以上是关于csharp CRM 2016 #Workflows#CRM2016 #MoussaElAnnan的主要内容,如果未能解决你的问题,请参考以下文章
csharp CRM 2016 #Emails#C#CRM2016 #MoussaElAnnan
csharp CRM 2016 #Client #Connection #CrmServiceClient#CRM2016 #MoussaElAnnan
csharp CRM 2015-2016 C ##Plugins #Metadata#CRM2016 #MoussaElAnnan
csharp CRM 2015-2016 C#Helper #Teams #Sharing#CRM2016 #MoussaElAnnan
csharp CRM 2016 C ## C ##OptionSets #MoussaElAnnan
Dynamics CRM 2015-Custom Workflow Activity