The CreatorCon Call for Content is officially open! Get started here.

How to Read Parameter from URL ?

SandeepKSingh
Kilo Sage

HiTeam,

I need to read "sysparm_stack"from the URL "u_demo_view.do?sys_id=-1&sysparm_stack=abc"and hide the filed using Client script.

How we can Achieve this ?

2 ACCEPTED SOLUTIONS

Ravi Gaurav
Giga Sage
Giga Sage

Hi @SandeepKSingh 

 

You can use the below onLoad Client script...

Your current URL is  "u_demo_view.do?sys_id=-1&sysparm_stack=abc"

 

 

   var currentURL = top.location.href;

    var urlParams = new URLSearchParams(top.location.search);

    var sysparm_stack = urlParams.get('sysparm_stack');

 

    if (sysparm_stack === 'abc') { 

        g_form.setDisplay('yourfieldname', false);

    }

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage
Giga Sage

Hi @SandeepKSingh 

 

You can use the below onLoad Client script...

Your current URL is  "u_demo_view.do?sys_id=-1&sysparm_stack=abc"

 

 

   var currentURL = top.location.href;

    var urlParams = new URLSearchParams(top.location.search);

    var sysparm_stack = urlParams.get('sysparm_stack');

 

    if (sysparm_stack === 'abc') { 

        g_form.setDisplay('yourfieldname', false);

    }

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/