A form script calls Xrm.WebApi.updateRecord("opportunity", id, { "parentaccountid": "ACCOUNT_GUID" }) to set the Account lookup, and the request fails with a bad request error. How should the data object be written?
Select an answer to reveal the explanation.
Short Explanation
A lookup isn't a plain value, it's a pointer, so you hand Dataverse an address: navigation property, @odata.bind, then the plural entity set path like /accounts(guid). Watch the trap: it's the entity set name, not the singular logical name.
Full Explanation
In the Dataverse Web API, which Xrm.WebApi wraps, a lookup is set by associating the row through its single-valued navigation property. The property name is followed by the @odata.bind annotation, and the value is a relative URI made of the target table's entity set name and the row ID, such as /accounts(guid). The entity set name is usually the plural form of the logical name, and it can be confirmed in the table's metadata. The _parentaccountid_value property is a read-only lookup property that appears in retrieve results; it cannot be written. An object with an id and an entityType is the format the form's attribute getValue and setValue methods use for lookups, which belongs to the form API and is not accepted by the Web API. Using the singular logical name in the URI is a common error: the URI must reference the entity set, so /account(...) does not resolve and the request fails. Exam caveat: for polymorphic lookups, such as a customer column that can point to an account or a contact, the navigation property name includes the target table, so the correct property depends on which table is referenced. Operational check: retrieve the table's EntitySetName from metadata, update one record from the console, and confirm the lookup shows the account on the form.