I was trying to Create an entity record using "Xrm.WebApi.createRecord" but I'm getting the Following error
"An error occurred while validating input parameters: Microsoft.Crm.CrmException: Invalid property 'edm_donorid' was found in entity 'Microsoft.Dynamics.CRM.edm_bookreceiptdetail'. ---> Microsoft.OData.ODataException: Does not support untyped value in non-open type."
please not that I'm sure that the field 'edm_donorid' exists in the form.
var data = { "edm_donorid": { "logicalname": "contact", "id": result["_edm_donorid_value"] } }; opener.Xrm.WebApi.createRecord("edm_bookreceiptdetail", data).then( function success(record) { console.log("record created with ID: " record.id); // perform operations on record creation }, function (error) { console.log(error.message); // handle error conditions } );
Hello,
Thank you all for your replies and your answers. I found the problem and I fixed it.
"cannot find record to be updated" error comes when I disregarded to fill a field that that have a relation with another entity.
so, make sure to fill every mandatory field or fields related to any other entities when you create an entity record using JS.
best regards,
Amer Azzam,
Microsoft Dynamics 365 Developer
Hi Amer,
Based on the code "result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty";", you retrieved another entity to get customer field value to create new records, Right?
I test with following code, which run successfully.
function createRecords(executionContext) { var formContext = executionContext.getFormContext(); Xrm.WebApi.online.retrieveRecord("incident", "5dda2b2e-d785-4474-b324-6225d4931000", "?$select=_customerid_value").then( function success(result) { var entity = {}; var type = result["_customerid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"]; if (type == "customerid_contact") { entity["parentcustomerid_contact@odata.bind"] = "/contacts(" result["_customerid_value"] ")"; } else if (type == "customerid_account") { entity["parentcustomerid_account@odata.bind@odata.bind"] = "/accounts(" result["_customerid_value"] ")"; } Xrm.WebApi.createRecord("contact", entity).then( function success(record) { console.log("record created with ID: " record.id); // perform operations on record creation }, function (error) { console.log(error.message); // handle error conditions } ); }, function (error) { Xrm.Utility.alertDialog(error.message); } ); }
Can you provide full code and more details of your scenario.
Or you can try to use power automate(https://us.flow.microsoft.com/en-us/) not code to create new records, which may be achieved more easily.
Use the Add a new row action to add a new row in Microsoft Dataverse.
Use a flow to add a row in Dataverse - Power Automate | Microsoft Docs
Please, don't create a new thread with exactly the same name - it is confusing.
Either close the thread marking the answer or keep adding new replies to the existing thread if something doesn't work/you need more details.
Merging those 3 threads you created.
I was trying to Create an entity record using "Xrm.WebApi.createRecord" but I'm getting the Following error.
"cannot find record to be updated"
please not that the field 'edm_donorid' exists in the form and the ID that I'm using to fill the fill also exists in the contacts.
var entity = {}; var type= result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"]; if(type== "edm_DonorID_contact") { entity["edm_DonorID_contact@odata.bind"] = "/contacts(" result["_edm_donorid_value"] ")"; } else if(type== "edm_DonorID_account") { entity["edm_DonorID_account@odata.bind"] = "/accounts(" result["_edm_donorid_value"] ")"; } opener.Xrm.WebApi.createRecord("edm_bookreceiptdetail", entity).then( function success(record) { console.log("record created with ID: " record.id); // perform operations on record creation }, function (error) { console.log(error.message); // handle error conditions } );
hello,
I fixed the error.
the field that i was trying to fill is of Type "Customer" and not "Lookup" so i fixed that by using the following code.
var entity = {}; var type= result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"]; if(type== "edm_DonorID_contact") { entity["edm_DonorID_contact@odata.bind"] = "/contacts(" result["_edm_donorid_value"] ")"; } else if(type== "edm_DonorID_account") { entity["edm_DonorID_account@odata.bind"] = "/accounts(" result["_edm_donorid_value"] ")"; }
Hello,
Thank You all for your replies.
I fixed the error.
the field that i was trying to fill is of Type "Customer" and not "Lookup" so i fixed that by using the following code.
var entity = {}; var type= result["_edm_donorid_value@Microsoft.Dynamics.CRM.associatednavigationproperty"]; if(type== "edm_DonorID_contact") { entity["edm_DonorID_contact@odata.bind"] = "/contacts(" result["_edm_donorid_value"] ")"; } else if(type== "edm_DonorID_account") { entity["edm_DonorID_account@odata.bind"] = "/accounts(" result["_edm_donorid_value"] ")"; }
hello Steve,
I faced the same problem when I changed it to the schema Name.
Hi,
I would advise you to download Rest Builder tool on your crm instance.
jlattimer.blogspot.com/.../crm-rest-builder-v2600.html
Tool will help you generate code for you.
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
Hi Amer,
This is caused because in your request you had the wrong field name, you need use the schema name of the lookup field followed by the bind annotation.
Go Settings > Customizations > Customize the System > Entities > select the entity you need > Fields to find the lookup field.
If it still doesn't work, you can refer following link to append the entity name to the schema name:
Hi Amer Azzam,
"edm_donorid" is your logical name, right? If so, please change it to schema name to have a try.
You could find it here:
Reference:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156