Reputation: 1
I have a Dynamics 365 CRM that my company is using and we have a bunch of custom tables that we've added, with a lot of lookup fields to each other. I'm trying to use javascript to update some of these lookup fields when certain events occur. I've followed the documentation (minimal as it is) My code based on this is:
Xrm.WebApi.updateRecord("new_nursesdatabase", "aa09e593-a624-ed11-b83e-000d3a371e11", {"[email protected]": "/new_personnelstatus_custom(5052e892-5aee-ec11-bb3d-000d3a5a2232)"}).then(function success(result) {console.log(result)})
where the first new_personnelstatus_custom
refers to the field in the new_nursesdatabase
and the second one refers to the table that the first field points to (I was not the one who created the logical names for these entities).
Running it I get this error:
[storage] Error Messages:
1: Error identified in Payload provided by the user for Entity :'', For more information on this error please follow this help link [Removed to avoid spam filter] InnerException : Microsoft.OData.ODataException: The navigation property 'new_PersonnelStatus_Custom' has no expanded value and no 'odata.bind' property annotation. Navigation property in request without expanded value must have the 'odata.bind' property annotation.
I followed the link provided in the error code, and was told by the documentation there to ensure that the navigation property exists, searching through the CSDL metadata document I did find the new_personnelstatus_custom field though it used the schema name new_PersonnelStatus_Custom rather than the logical name I used above, changing that and running:
Xrm.WebApi.updateRecord("new_nursesdatabase", "aa09e593-a624-ed11-b83e-000d3a371e11", {"[email protected]": "/new_personnelstatus_custom(5052e892-5aee-ec11-bb3d-000d3a5a2232)"}).then(function success(result) {console.log(result)})
But I get this error message:
[storage] Error Messages:
1: URL was not parsed due to an ODataUnrecognizedPathException. Resource not found for the segment provided in the URL.
(Capitalizing the table name made no difference). I'm not certain if this is forward progress or backward progress as if I misspell the field name with the capitalizations it gets me the first error so it's clearly recognizing this entity as opposed to the non-capitalized version which it seems to treat the same as a made-up field. This is a single-valued lookup field, that is it can only have one value at a time and can only refer to one table so it's not a multi-table lookup issue, the GUIDs provided were taken directly from the record so should be accurate (and I expect that I would get a different type of error were everything else working and they were wrong). I've scoured the internet but have not found any indications that the code shouldn't work as written.
Upvotes: 0
Views: 2321
Reputation: 1
You have figured out the problem, but in case anyone is running into problems in the future here - Dynamics API requires table names to be in plural (contact -> contacts), but if your table is already named contacts, you need to use "contactses" (add -es). Welcome to this absurdity.
Upvotes: 0
Reputation: 1
After using the Dataverse REST builder provided by Guido Preite, I was able to find the missing letter that was causing problems. Apparently you need to use the schema name for the column, and it seems like you need to use the "plural logical" name for the table. I didn't find any reference to the logical name and I'd have to dig into the code underlying the REST builder to figure out where it found this, but apparently I needed to use new_personnelstatus_customs instead of new_personnelstatus_custom for the table despite new_personnelstatus_customs being neither the logical name (new_personnelstatus_custom) nor the schema name (new_PersonnelStatusCustom) and I can only assume that either Dataverse pluralized the logical name of the table in certain contexts which is bizarre if true.
Upvotes: 0