View rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 12:56 AM - edited 05-29-2023 01:10 AM
Hi All 😊
I need in the incident table:
1. Create a new view named: manager view
2. Create a new choice field called "selected view" (contains 2 options: default view, manager view)
3. When selected view = manager view --> The view of the incident will be manager view,
and when selected view = default view The view of the incident will be the default view
I did task 1 and 2
How can I do task 3 using view rule?
The view should change automatically (and not manually) according to the value of the field - "selected view".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 01:13 AM
Hi @Danit Shabtay ,
You need to create an onChange client script to change views dynamically based on the choice selected.
Client script : type - onChange, Field - selected view
Please check if the backend names of choice and view is same, if not - change it accordingly in the script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue == 'manager_view'){
switchView('section','incident','manager_view');
}
else if(newValue == 'default_view'){
switchView('section','incident', 'default');
}
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 01:13 AM
HI @Danit Shabtay ,
I trust you are doing great.
To achieve task 3 using view rules in ServiceNow for the incident table, you can follow these steps:
- Go to the ServiceNow platform and navigate to the "Incident" table.
- Open the "View Rules" module.
- Create a new view rule by clicking on the "New" button.
- Provide a name for the view rule, such as "Automatic View Change".
- In the "Table" field, select "Incident" to specify that the view rule is for the incident table.
- In the "When to run" section, choose the option "Before query is executed".
- In the "Advanced" section, specify the following condition:
- Condition: selected_view
- Operator: is
- Value: manager view
- In the "Actions" section, select the option "Set the active view" and choose "Manager View" as the view to be activated.
- Click on the "Save" button to save the view rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 04:44 AM
6 - In the "When to run" section, choose the option "Before query is executed".
Where is this option? There is no "When to run" on view rules?