Error in saving data(input) to data sets(collections) after adding IF statement

i’m facing an issue with saving the data, I have two collections (client and sessions), I wrote a code by IF statement that inserts the inputs only if they are valid. It works well with the client collection but it doesn’t save the inputs to the other collection(sessions) although they have the same codes and settings. However, without the IF statement code, the inputs are saved in both collections.

Maybe the Session collection is set to read-only or limited to admin only. Check the permissions.

Thank you J.D for your answer, I checked the permissions nothing is wrong with it, actually it is write only cuz it`s a form that is needed to be filled by the client

Hi! Could you provide the site URL, please?