The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Is it possible to create a script depending on the module accessed?

Rain Vaine
Kilo Sage

Hello experts,
Do you know of any method that can trigger a script based on the module that is accessed?
For example, the client script will only run if this module is clicked:

RainVaine_0-1706839304039.png


We cannot use the view parameter since we are just using the same views. Except there is different module with different URL argument. Is it possible to add a tag in URL argument for when that module is clicked?

Regards, 
Vaine

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Rain Vaine 

ensure your client script runs on all views

simply in the client script check the URL and see the module sysId and then add your logic

check this parameter in the URL -> sysparm_userpref_module=

AnkurBawiskar_0-1706857431465.png

 

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

Hello,
How do you get that URL value in the client script? 

For getting view, there is a method g_form.getParameter('view') to get the view, is there also a method for getting the module?

Regards,
Vaine