Database queries working in preview but not in published site.

https://www.psquareinternational.com/test-1

Here, 50 questions are accessed from a database of questions.

When we click submit, a few questions do not get scored (see error-logging in the console). The code can’t seem to find those dataset entries. The preview mode test works perfectly.

I made sure they are there in the dataset. Why do they not get scored properly?

Check your database permissions.

But similar queries work for more than half the items in the repeater and not for the other half. Kindly take a look at the developer’s console to see what I mean.

@bhavikakhare When something works in Preview but not in Live it is most likely some type of permission or setting error. When the error is code, logic or element setting it will not work at all.

If you are testing anything that has to do with ‘who is logged in’ ---- and if it works in Preview ---- know that the editor will always detect an Admin as the tester (unless otherwise coded by you). If you are checking on the live site, and running a code that is dependent on who is logged in or how they are tagged, etc ----- and it is not working, then it has to do with Permissions. I recommend to check your permissions.

Here is troubleshooting article that explains the most popular errors that cause things to work in Preview but not on the Live site (#1 and #2 are most likely the cause of your error):

https://www.totallycodable.com/post/data-visible-in-preview-but-data-not-visible-on-published-website