Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Catalog client script for making a variable bold is working on DEV but not on PROD

Nishitha Yedala
Tera Contributor
I have the below catalog client script, It is working fine on DEV instance but not PROD . 
The isolate script is also set to false
 
Unable to find the reason.




function
onLoad(){

    setTimeout(function(){
       

            // portal
            var aTags = this.document.getElementsByClassName("ng-binding");
            var searchText = "Please enter the S1 Site name manually if it is not available in the list above (e.g. 099 - Test Site):";
            var found;

            for (var i = 0; i < aTags.length; i++) {
                if (aTags[i].textContent.toString() == searchText) {
                    aTags[i].style.fontWeight = 'bold';
                    aTags[i].style.fontSize = '15px';
                    aTags[i].style.paddingLeft = '6px';
                    break;
                }
            }
       

    }, 1000);

}  


7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Nishitha Yedala 

may be the timeout is less for PROD

In PROD the page is taking time to load

Try increasing the timeout to 5 seconds and migrate the update set and then check

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Nishitha Yedala 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Shubham_Jain
Mega Sage
Mega Sage

@Nishitha Yedala 

 

 DOM Access Differences

  • The script uses document.getElementsByClassName("ng-binding"), which is DOM-dependent.
  • If the portal theme or layout differs between DEV and PROD, the class names or structure might not match.
    • Try inspecting the portal in PROD using browser dev tools to confirm if "ng-binding" is present.

Script Load Timing

  • You're using setTimeout with 1000ms. If the DOM isn't fully loaded by then in PROD, it might fail.
    • Try increasing the timeout to 2000ms or use a more reliable method like window.onload or MutationObserver.

Browser Console Errors

  • Check the browser console in PROD for any JavaScript errors that might be blocking execution.

 

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain