AddLoadEvent

BrandonReed
Giga Contributor

I am learning more about ServiceNow.

I have modified a UI script that redirects users with certain permissions. However, I'm attempting to modify this script and none of the console logs, alerts or JSLOGs are showing up on my addloadevent script. 

My thought is that there is a conflict with the addloadevent but it seems i need to get access to g_user and using any other load function sets g_user as undefined.

1 REPLY 1

Ratnakar7
Mega Sage
Mega Sage

HI @BrandonReed ,

 

You can try the following steps to debug:

  1. Double-check that the function you want to run is being passed to the addLoadEvent function correctly. Make sure the syntax is correct and there are no syntax errors in your code.

  2. Check that the addLoadEvent function is being called correctly. Make sure it is being called after the function you want to run has been defined.

  3. Check if any errors are being thrown in the console. This could indicate that there is a problem with your code that is preventing it from running.

  4. Try using console.log statements inside your addLoadEvent function to debug. Make sure the console is open and check if the log statements are appearing.

  5. Try running the function directly without using addLoadEvent. If the function runs correctly without addLoadEvent, it could indicate that there is a problem with the timing of the addLoadEvent function.

  6. Finally, check if there are any other scripts on the page that could be conflicting with your code. Make sure there are no syntax errors or other issues in those scripts that could be causing conflicts.

Also, refer https://servicenowguru.com/system-ui/ui-scripts-system-ui/dynamic-browser-window-title-script/

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar