Category: Question and Answers
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Can’t get to my Page JS Object and APIs

Issue

I am having trouble accessing my Splash screen and its JS Object and APIs because the initial check for user login is causing the page to immediately route me to the login screen even when I am in edit mode. I can't access the function to turn off the onpage execution and am considering starting the splash screen over. I received a suggestion to use the appsmith.mode parameter to avoid this and it worked. However, it would be helpful to have a "Disable Code" option in the page's context menu to easily overcome similar scenarios in the future.

Resolution

The user was experiencing an issue with their initial splash screen on their app which was checking to see if a user was logged in and then redirecting them to the appropriate page. However, this function was also executed when the app was in edit mode and caused the user to be immediately routed to the login page, making it difficult for them to access the function to turn off the onpage execution. To solve this issue, another user suggested using the appsmith.mode parameter to add a check for view mode before executing the function. This way the function would only be executed when the app was in view mode and not in edit mode. The user was then able to wrap their function with an IF statement using the appsmith.mode parameter and prevent it from executing in edit mode. This solution helped the user access the page's JS Objects and datasources. They also suggested that having a "Disable Code" option in the page context menu would be helpful in these kinds of situations.

Here's an example of how to wrap a function with an IF statement using the appsmith.mode parameter:

if({{appsmith.mode}} === "view") {
// execute function here
}