- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 06:05 AM
Hey guys!
I have an issue where I need to update the view for the end-user regarding a table called rm_story. The standard view is 'scrum'. However I want the view to change to one called 'rd_' if the user fills two specific values in the 'Assignment Group' field.
This was the original script for an already existing View Rule:
I updated it to this, which still did not work when I chose either of the two specified Assignment Groups and updated the record:
Any ideas?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 10:23 AM
If I got this right - you want to present a view to the end user (let's say view A), but if you the user fills some fields to show another view (view B) ?
If this is the case this wont work until you same the form and rerender it.
I'd say you need UI policy here or Client Script to handle such a requirement. Using view for that wont be best approach - doable but will take you time and scripting, not worth the effort.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 10:49 AM
SO g_form mayn't work in view rule. You can try below script to get the record and then check the assignment group value.
var url = gs.action.getGlideURI().getMap();
var sysId = url.get('sys_id');
var gr = new GlideRecord('table_name');
if (gr.get(sysId)) {
gr.field_name;
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 10:23 AM
If I got this right - you want to present a view to the end user (let's say view A), but if you the user fills some fields to show another view (view B) ?
If this is the case this wont work until you same the form and rerender it.
I'd say you need UI policy here or Client Script to handle such a requirement. Using view for that wont be best approach - doable but will take you time and scripting, not worth the effort.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 10:29 AM - edited 12-08-2023 10:32 AM
As I mentioned above as a way - scripting/custom stuff - you can change the view by maniulating the URI. From there you can force different view depending on your conditions (in your case your assignment group values).
This is an example forcing a view
&sysparm_view_forced=true&sysparm_view=rd_
You need to append this to the URI via client script on given condition. This should reload the form I believe.
Havent tested it now, but I believe you need to pass the value of assignt_group as well there - otherwise you will loose it on reloading the form with your forced view. Or you need to save it first and then it's much easier to handle it - Use CSJS - onChange - your trigger/condition -> use g_form.save() -> then your form will be saved and on reload the new view will be shown using the view rules as you attenped before.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2023 10:49 AM
SO g_form mayn't work in view rule. You can try below script to get the record and then check the assignment group value.
var url = gs.action.getGlideURI().getMap();
var sysId = url.get('sys_id');
var gr = new GlideRecord('table_name');
if (gr.get(sysId)) {
gr.field_name;
}
Please mark this response as correct or helpful if it assisted you with your question.