joi, 26 februarie 2015

How to use early bound entities in the context of an workflow

How to use early bound entities in the context of an workflow :

IWorkflowContext context = executionContext.GetExtension();

IOrganizationServiceFactory serviceFactory = executionContext.GetExtension();

//YourServiceContext = the name of crm context 
var type = Type.GetType("Microsoft.Crm.Workflow.SynchronousRuntime.WorkflowContext, Microsoft.Crm.Workflow, Version=5.0.0.0"); 

type.GetProperty("ProxyTypesAssembly").SetValue(serviceFactory,typeof(YourServiceContext).Assembly, null); IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);