window.location is not working in UI script it is working only once

chaitanya8
Tera Contributor

window.location is not working in UI script it is working only once, but UI pages loads twice in our requirement once when the user logins, and then user clicks on any widget then also it runs second time, the thing is when i tested by adding alert's the first time when the user logins it is fetching URL perfectly but second time when we click on widget then it is unable to fetch the URL is there any alternative for this ? and also i want to know whether myVariable.includes(searchTerm) , window.location.assign() will work in UI script ?  and for this issue work around  window.location , i am using top.location.href it is fetching URL.

1 REPLY 1

sourav1999
Mega Guru

• Check the syntax of the window.location code.

• Ensure that the window.location code is inside the correct function.

• Check the browser console for any errors.

• Make sure the window.location code is not inside an iframe.

• Check the URL for the window.location code.

• Make sure the window.location code is not being overridden by another script.

 

For asking ServiceNow-related questions try this :

For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.

Link - https://nowgpt.ai/

 

For the ServiceNow Certified System Administrator exams try this :

https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER