Show UI action based on the URL parameter

Naga Ravindra R
Kilo Sage

I have a table name "A" on which I have an UI action "X". I want to show this UI action only in one particular module, i.e., when User clicks on that module in the navigator, the URL should be "https://xxxxxxx.service-now.com/x_scoped_app_list.do?sysparm_userpref_module=5b0fb84447de35502bb635a..."

 

Background: when user clicks on this, it will open one catalog item on portal.

I have conditions like below:

 

(gs.hasRole("x_scoped_app.manager") && !(RP.getParameterValue('sysparm_view') == 'sys_ref_list')) && (!(RP.isRelatedList())) && (gs.action.getGlideURI().getMap().get('sysparm_userpref_module') == '5b0fb84447de35502bb635a2e36d4312');

 

 

But this is not working, any suggestions on this?

 

 

4 REPLIES 4

Shivam Techlene
Tera Guru

Hi @Naga Ravindra R ,

 

Try the code given below:

if(gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI().indexOf('<string_to_search>') != -1)

 

The code above will check for the value you will be giving inside the indexOf function in the current URL.

 

Kindly mark it helpful and correct if it helps resolving your requirement!

 

Thanks & Regards,
Shivam Jaiswal

Hi @Naga Ravindra R ,

 

Did you get a chance to try this one?

 

Kindly mark my response helpful and correct if it helps resolving your requirement.

 

Thanks & Regards,
Shivam Jaiswal

Naga Ravindra R
Kilo Sage

I have added the following condition:

 

gs.hasRole("x_scopedd_manger_role") && !(RP.getParameterValue('sysparm_view') == 'sys_ref_list') && RP.getParameterValue("sysparm_userpref_module") == '5b0fb84447de35502bb635a2e36d4312'

 

UI action is working fine, but when I clicked on UI action it is not working.

Below is my code in my UI action:

action.setRedirectURL('sp?id=sc_cat_item&sys_id=d164a1fb1b35b9108f889863b24bcbee');

Hi @Naga Ravindra R ,

 

Please try the below code line:

action.setRedirectURL('/sp?id=sc_cat_item&sys_id=d164a1fb1b35b9108f889863b24bcbee');
 

Please hit the like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

 

Thanks & Regards

Jyoti Jadhav