How to check if URL contains specific keyword in catalog client scripts

BijoyDeb
Tera Contributor

Hi all,

On salesforce side, we have one button which if clicked, users are redirected to order guide in SNOW to submit.

The URL while this OG is rendered, it contains few parameters as well which we paste on OG variables.

I've a requirement that if this order guide is opened from salesforce (hence it will have those parameters in URL), then hide choices of lookup select box variable that is under a variable set added on this OG.

 

This order guide is in custom app, and hence I wanted help on how I can check for those keywords in URL and remove choices from variable?

1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@BijoyDeb You can use below code to get the parameters from URL. You need to use onLoad client script.

 

var url = top.location.href;  // this will get the browser URL 
var urlObj = new URLSearchParams(url);
var variable_name= urlObj.get('sys_id')  // put your parameter name here in place of sys_id

 

Once you get the parameter value then based on it you can write you logic of hiding select box variable.

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

View solution in original post

3 REPLIES 3

SANDEEP28
Mega Sage

@BijoyDeb You can use below code to get the parameters from URL. You need to use onLoad client script.

 

var url = top.location.href;  // this will get the browser URL 
var urlObj = new URLSearchParams(url);
var variable_name= urlObj.get('sys_id')  // put your parameter name here in place of sys_id

 

Once you get the parameter value then based on it you can write you logic of hiding select box variable.

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

mayankkumar
Kilo Patron

Hi @BijoyDeb,
----------------------------------------------------------------------------------------------------------------------------------------
I implemented the same requirement as this in the widget client script

 var currentURL = top.location.href;
        if (currentURL.includes("/now/"))

Like this you can achieve your business requirement
I hope it helps and do let me know if you still have any query.
-------------------------------------------------------------------------------------------------------------------------------------------
Please Mark my Response Helpful and Accept as solution.
Thanks & Regards
Mayank

mayankkumar
Kilo Patron

Hi @BijoyDeb,
I think your query is resolved
You can accept multiple solution if my response is also correct
---------------------------------------------------------------------------------------------------------------------------------------------
Please Mark my Response Helpful and Accept as solution.
Thanks & Regards
Mayank