I'm attempting to resolve this error in a MongoDB insertOne query while loading an application.
Error: Cannot read properties of null (reading '_id')
insertOneDerivedAttribute!
from insertOneDerivedAttribute.query update(insertOneDerivedAttribute)
from derivedAttributes.selectedRow update(derivedAttributes)
from user interaction
The query is really simple:
{
"derivedAttributeName": {{ formDerivedAttribute.data.textInputInternalName }},
"derivedAttributeType": {{ formDerivedAttribute.data.selectDerivedAttributeType }}
}
Do you want the query to run on first load? I am imagining this issue is occurring due to the data not yet being loaded into the form when the query is running on load.
No, I don't want to run on first load.
Since the query's Run behavior is set to Manual, I really don't know why it is trying to run on the first load.
I tried to put a condition in the Advanced -> Disable query without success.
Hi, @uelintons. Happy to help!
Does the modal have that title by default? Although the modal is closed, this may be the reason why the query is running on app load.
I'm afraid not.
The trigger needs to be related to the modal's submit button to insert a new document into the collection, only if the form has the "Add..." title.
If I turn to manual the query attached to the table element, the warning disappears. So I think this query is triggering somehow the insert query. But then I need to put an event handler to run the table query, which is not a good choice.
Is there a way to check if the page is loading? If so, I can add this condition to the "Only run when" condition of the event handler.