OnLoad Client Script Adding "realms" View to sc_req_item URLs

kevin_munguia
Tera Guru

Does anyone have an existing template onload client script for the following scenario?

I want to add the "realms" view to the URL of a (sc_req_item) record in ServiceNow. I want this to happen automatically whenever someone opens an existing request item. I don't want to have to click a button or do anything manually so it takes the current URL, adds the necessary parameters for the "realms" view, and then immediately redirects the page so the user sees the request item with the "realms" view applied.

in snow my current URL looks like:

 

/now/nav/ui/classic/params/target/sc_req_item.do%3Fsys_id%3DMYSISIDHERE%26sysparm_record_target%3Dtask%26sysparm_record_row%3D1%26sysparm_record_rows%3D5%26sysparm_record_list%3Dassignment_group%GROUPIDHERE%255Eactive%253Dtrue%255EORDERBYDESCsys_updated_on

 

but I want to add realms to the locations in the example below when a record loads for sc_req_item table:

 

/now/nav/ui/classic/params/target/sc_req_item.do%3Fsysparm_record_list%3Dassignment_group%GROUPIDHERE%255Eactive%253Dtrue%255EORDERBYDESCsys_updated_on%26sysparm_record_rows%3D5%26sysparm_record_row%3D1%26sysparm_record_target%3Dtask%26sys_id%3DSYSYIDHERE%26sysparm_view%3Drealms%26sysparm_userpref.sc_req_item.view%3Drealms%26sysparm_userpref.sc_req_item_list.view%3Drealms

2 REPLIES 2

Martin Friedel
Mega Sage

Hello,

is it necessary to you client script? ServiceNow has View Rules option that meets your requirement.

  1. Simply go to System UI > View Rules
  2. Create a new View Rule
  • View Rule is used to dynamically determine which form view should be displayed to a user based on specific conditions.
  • You can create a new View Rule in table View Rules [sysrule_view] (Check already existing view rules to get an idea how they are configured)
    • View: Name of view you have created
    • Conditions: Current user is Regional Manager

Related Community article created by Amit Gujarathi: ServiceNow View and View Rule | ServiceNow tutorial to understand the view and view rule with ease.  

 

If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin

Ankur Bawiskar
Tera Patron
Tera Patron

@kevin_munguia 

what's your business requirement here?

Do you want different users to see different RITM form views?

If yes then you can setup View Rules for the same

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