Error in a MongoDB insertOne query when loading app

Hello there,

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 }}
}

image

Could somebody help me?

Any thoughts are welcome.

Thanks,

Hey @uelintons, welcome to the forums! Would you be able to provide more context / send a screenshot of your query?

Hey @jamesg31,

Thanks for replying.

Sure, here the context:

I have a modal with a form to add new documents to the derivedAttributes collection in MongoDB.

Here the query screenshot:

These are the form's Submit button event handlers
image
image
image

The query works as expected from submitting new documents/records.

The error occurs only on the app's load.

Thanks in advance,

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.