Hi CRM Experts,
I have written a Workflow activity with a couple of out arguments that are of type EntityReference
[Output("Approver")]
[Default(null)]
[ReferenceTarget("systemuser")]
public OutArgument<EntityReference> Approver { get; set; }
[Output("Next Milestone")]
[Default(null)]
[ReferenceTarget("wen_milestonetype")]
public OutArgument<EntityReference> NextMilestone { get; set; }
I have set default values and the workflow throws out the error below, when I'm trying to update a date field in one of the related entities
Guid milestoneid = getNextMilestoneId(MilestoneType, ProjectID);
Entity milestone = new Entity(Constants.Milestone.EntityName);
milestone.Id = milestoneid;
milestone[Constants.Milestone.ActualDate] = DateTime.Now;
this.Context.SystemOrgService.Update(milestone);
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An exception has occurred in the [Wendys.Crm.WorkflowPlugins.Budget.PopulateBudgetApprovalsOnMilestone] plugin.
An unhandled organization service fault occurred during execution of the workflow activity.
Entity Reference cannot have Id and Key Attributes empty.Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>3ad07b18-36a4-418b-9cf9-dae0ed97c17e</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:int">0</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:int">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>An exception has occurred in the [Wendys.Crm.WorkflowPlugins.Budget.PopulateBudgetApprovalsOnMilestone] plugin.
An unhandled organization service fault occurred during execution of the workflow activity.
Entity Reference cannot have Id and Key Attributes empty.</Message>
<Timestamp>2018-07-03T00:38:07.6531954Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource>SdkClient</ExceptionSource>
<InnerFault>
<ActivityId>106d9572-7dea-4845-9795-27cb6957247e</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d3p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d3p1:key>OperationStatus</d3p1:key>
<d3p1:value xmlns:d5p1="www.w3.org/.../XMLSchema" i:type="d5p1:int">0</d3p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d3p1:key>SubErrorCode</d3p1:key>
<d3p1:value xmlns:d5p1="www.w3.org/.../XMLSchema" i:type="d5p1:int">-2146233088</d3p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Entity Reference cannot have Id and Key Attributes empty.</Message>
<Timestamp>2018-07-03T00:38:07.6778127Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource>SdkClient</ExceptionSource>
<InnerFault>
<ActivityId>106d9572-7dea-4845-9795-27cb6957247e</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d4p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d4p1:key>OperationStatus</d4p1:key>
<d4p1:value xmlns:d6p1="www.w3.org/.../XMLSchema" i:type="d6p1:int">0</d4p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d4p1:key>SubErrorCode</d4p1:key>
<d4p1:value xmlns:d6p1="www.w3.org/.../XMLSchema" i:type="d6p1:int">-2146233088</d4p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Entity Reference cannot have Id and Key Attributes empty.</Message>
<Timestamp>2018-07-03T00:38:07.6778127Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault>
<ActivityId>106d9572-7dea-4845-9795-27cb6957247e</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d5p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d5p1:key>OperationStatus</d5p1:key>
<d5p1:value xmlns:d7p1="www.w3.org/.../XMLSchema" i:type="d7p1:int">0</d5p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d5p1:key>SubErrorCode</d5p1:key>
<d5p1:value xmlns:d7p1="www.w3.org/.../XMLSchema" i:type="d7p1:int">-2146233088</d5p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Entity Reference cannot have Id and Key Attributes empty.</Message>
<Timestamp>2018-07-03T00:38:07.6778127Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<OriginalException i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<OriginalException>System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault] with ErrorCode: -2147220891
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext)
There are no null Guids when I retrieve the records and the out arguments are set with values and the field name (that I'm retrieving to update) matches with schema name. I searched for this error resolution online for quite sometime couldn't find anything other than "we have to default the out arguments to null"
https://community.dynamics.com/crm/f/117/t/254349
https://community.dynamics.com/crm/f/117/t/253463
Any help or suggestion is appreciated.
Thanks,
Vinod
*This post is locked for comments