Hello,
I am working on a functionality where I am on an entity - Customer Leads. Now, in this entity we have a HTML web resource embedded on the form. On click of a button in that web resource, it needs to create a new record of the entity Customer appointment. The customer appointment entity has a few party list fields - regardingobjectid, from, to. I am trying to set the values for these party list fields and its not working for me. I researched some of the forums out there but everything is providing a solution only to create in the same entity. Not sure how to do it in a different entity. This is what am doing:
let regardingobjectidvalues = [];
regardingobjectidvalues.push({
id: customerleadId,
name: "Jane Doe",
entityType: "ed_customerlead"
});
let data = {
regardingobjectid: regardingobjectidvalues,
"ownerid@odata.bind": `/systemusers(${currentUserId})`,
subject: value,
description: value,
}
Xrm.WebApi.createRecord("ed_customerappointment", data).then(
function success(result) {
console.log("Success: " + result.id);
// perform operations on record creation
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
Error message:
An error occurred while validating input parameters: Microsoft.OData.ODataException: Does not support untyped value in non-open type.
at System.Web.OData.Formatter.Deserialization.DeserializationHelpers.ApplyProperty(ODataProperty property, IEdmStructuredTypeReference resourceType, Object resource, ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.ApplyStructuralProperties(Object resource, ODataResourceWrapper resourceWrapper, IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)
at Microsoft.Crm.Extensibility.CrmODataEntityDeserializer.ApplyStructuralProperties(Object resource, ODataResourceWrapper resourceWrapper, IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.ReadResource(ODataResourceWrapper resourceWrapper, IEdmStructuredTypeReference structuredType, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)