'View Rule' not working - update view for table

ronro2
Tera Contributor

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: 

ronro2_0-1702044200272.png


I updated it to this, which still did not work when I chose either of the two specified Assignment Groups and updated the record: 

ronro2_1-1702044265636.png
Any ideas? 

 

2 ACCEPTED SOLUTIONS

Community Alums
Not applicable

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.

 

View solution in original post

SanjivMeher
Kilo Patron
Kilo Patron

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.

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

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.

 

Community Alums
Not applicable

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.

SanjivMeher
Kilo Patron
Kilo Patron

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.