-
Notifications
You must be signed in to change notification settings - Fork 411
Description
[x] Question using release 3.19.0
I am attempting to set the value of a Lookup field in the onbeforesubmit method invoked by a DynamicForm control. When I try to create a new list item from the dynamic form the onbeforesubmit is intended to set the value of a lookup field to a specific Id.
component from render:
<DynamicForm webAbsoluteUrl={'https://xxxxxx.sharepoint.com/sites/Intranet'}
listId={"<list guid>"}
onCancelled={() => { this.setState({ showNewTask: false }) }}
onBeforeSubmit={this._newTaskOnBeforeSubmit}
onSubmitError={(listItem, error) => { alert(error.message); }}
onSubmitted={async (listItemData) => {
this._closeTaskPanel();
}}
context={this.props.context as any}
hiddenFields={["Case"]}
/>
method I am testing:
private _newTaskOnBeforeSubmit = async (listItemData: any): Promise<boolean> => {
try {
console.log("In _newTaskOnBeforeSubmit...")
console.log(this.state.selectedCaseId)
const usethisId: number = this.state.selectedCaseId;
listItemData.Case = {
"__metadata": { "type": "SP.FieldLookupValue" },
"LookupId": usethisId
};
return false;
}
catch (err) {
alert(err);
return true;
}
}
The "Case" field is a simple lookup to another list in the same web and was created with default Title option. Works fine in sharepoint online out of the box forms.
When I use the DynamicForm to create a new list item I get the following error when clicking [Save]:
Error making HttpClient request in queryable [400] ::> {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Incompatible type kinds were found. The type 'SP.FieldLookupValue' was found to be of kind 'Complex' instead of the expected kind 'Entity'."}}}
