I have created a custom table named dev_application, which includes a Contact lookup field (dev_applicationcreatedby).
When I try to create a record using server-side logic and include a value for this Contact lookup field, the request fails with an error from Dataverse. However, the record is created successfully when I exclude the lookup field. If I remove the lookup field from the payload, everything works as expected. I have verified that the current user ID exists in the Contact table. I have also assigned all required table permissions to the authenticated user web role.
Could someone please help me understand what might be wrong with the lookup configuration or payload format? Any guidance would be greatly appreciated.
function post() {
try {
Server.Logger.Log("POST called");
const data = JSON.parse(Server.Context.Body);
const entitySetName = Server.Context.QueryParameters["entitySetName"];
var userid = Server.User.contactid;
data["dev_applicationcreatedby@odata.bind"] = `/contacts(${userid})`
return Server.Connector.Dataverse.CreateRecord(entitySetName, JSON.stringify(data));
} catch (err) {
Server.Logger.Error("POST failed: " + err.message);
return JSON.stringify({ status: "error", method: "POST", message: err });
}
}