I believe this question is different than the one linked here:
CRM do not support direct update of Entity Reference properties, Use Navigation properties instead
I have a global action that accepts a ClubOfficer
Entity as a required input argument. Here is a sample of the payload my code is generating:
{
"ClubOfficer":{
"_ti_club_officer_code_value":"6efab90f-7d2b-e811-a957-000d3a34a108",
"ti_club_id":{
"accountid":"cbf646cb-a232-e811-a959-000d3a34a0aa"
},
"ti_member":{
"contactid":"e318472c-c732-e811-a959-000d3a34ae50"
},
"ti_start_date":"2018-07-01T00:00:00Z",
"ti_end_date":"2018-12-31T23:59:59Z"
},
"Term":"Current"
}
However, before that action is even called it fails with the error:
{
"error": {
"code": "0x0",
"message": "CRM do not support direct update of Entity Reference properties, Use Navigation properties instead.",
"innererror": {
"message": "CRM do not support direct update of Entity Reference properties, Use Navigation properties instead.",
"type": "Microsoft.Crm.CrmHttpException",
"stacktrace": " at Microsoft.Crm.Extensibility.OData.TypeConverters.EntityReferenceAttributeTypeConverter.ConvertToCrmTypeInternal(Guid edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmTypeConverterBase`2.ConvertToCrmType(Object edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmEntityTypeConverter.SetStructuralPropertyToXrmEntity(Entity entity, EntityMetadata entityMetadata, String crmAttributeName, IEdmProperty edmProperty, Object propertyValue)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmEntityTypeConverter.ConvertToCrmTypeInternal(EdmEntityObject edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmTypeConverterBase`2.ConvertToCrmType(Object edmTypeValue)\r\n at Microsoft.Crm.Extensibility.ODataV4.Converters.TypeConverters.OnDemandEdmEntityTypeConverter.ConvertToCrmTypeInternal(EdmEntityObject edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmTypeConverterBase`2.ConvertToCrmType(Object edmTypeValue)\r\n at Microsoft.Crm.Extensibility.OData.RequestResponseConverter.AddSDKRequestParameterFromEdmOperationParameter(IEdmModel edmModel, IEdmOperation edmOperation, ParameterCollection parameterCollection, KeyValuePair`2 parameter, Tuple`2 messagePair)\r\n at Microsoft.Crm.Extensibility.OData.RequestResponseConverter.GetRequestParamsFromOperationRequest(IEdmModel edmModel, IEdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters, Tuple`2 messagePair, Dictionary`2 offlineData)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.ExecuteOperation(CrmODataExecutionContext context, EdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.ProcessOperationRequest(String operationName, Dictionary`2 operationParameters, EntityReference entityReference, String boundEntityName, String boundEntityType)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.<>c__DisplayClass9_0.<PostUnboundAction>b__0()\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
}
}
The ClubOfficer is not an existing entity, but rather I would like the Action to treat it as a ClubOfficer temporary entity so that I can take advantage of the "type safety" of the entity properties. Is that possible? Or do I have to pass ClubOfficer as a String argument and then operate on the JSON string? What is this error complaining about and how do I fix it?