HI,
I am trying to create optionset value in custom workflow but its saying
You cannot start a transaction with a different isolation level than is already set on the current transaction error in Plugin.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Metadata; using Microsoft.Xrm.Sdk.Messages; using Microsoft.Xrm.Sdk.Query; using Microsoft.Xrm.Sdk.Workflow; using System.Activities; namespace Importglo { public class Class1 : CodeActivity { protected override void Execute(CodeActivityContext executionContext) { ITracingService tracingService = executionContext.GetExtension<ITracingService>(); IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); try { ////Read configuration ////Read configuration QueryExpression optionsetconfig = new QueryExpression() { EntityName = "ss_bulkoptionset", ColumnSet = new ColumnSet(true), Criteria = { Conditions = { //new ConditionExpression("fz_name", ConditionOperator.Equal, "Configurations"), //new ConditionExpression("statecode", ConditionOperator.Equal, 0) } } }; EntityCollection _Records = service.RetrieveMultiple(optionsetconfig); foreach (Entity _Entity in _Records.Entities) { // tracingService.Trace("accountPlugin: {0}", _Entity.Attributes["fz_optionset"]); InsertOptionValueRequest insertOptionValueRequest = new InsertOptionValueRequest { Value = Convert.ToInt16(_Entity.Attributes["ss_optionset"]), OptionSetName = _Entity.Attributes["ss_name"].ToString(), Label = new Label(_Entity.Attributes["ss_optionsetlabel"].ToString(), 1033) }; //execute the request InsertOptionValueResponse optionResponse = (InsertOptionValueResponse)service.Execute(insertOptionValueRequest); // tracingService.Trace("accountPlugin: {0}", _Entity.Attributes["fz_optionset"]); } } catch (Exception ex) { tracingService.Trace("accountPlugin: {0}", ex.ToString()); throw; } } [Input("Test")] public InArgument<string> Test { get; set; } } }
*This post is locked for comments