- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 06:39 AM
Hello,
Is there a way to override view rules for a SINGLE Incident instead of LIST -> Incident. Basically, what I am trying to achieve is to change view based on INCIDENT CATEGORY apart of already existing view rule based on company. I have 2 view rules that interact with each other and only works properly if one is disabled.
View rule 1:
(function overrideView(view, is_list) {
var url = gs.getProperty("glide.servlet.uri") + gs.action.getGlideURI();
var url2 = gs.action.getGlideURI().getMap();
var sysId = url2.get('sys_id');
var isMember = gs.getUser().isMemberOf('HSE TEST');
if(!url.includes("sys_id=-1")&&url.includes("incident.do")){
var company = "";
var category = "";
var gr = new GlideRecord('incident');
if (gr.get(sysId)) {
company = gr.company;
}
if(isMember !== true){
if(company === 'SOME ID' || company === "SOME ID" || company === "SOME ID"){
answer = 'SOME VIEW NAME';
}
else if (company === 'SOME ID') {
answer = "SOME VIEW NAME"; // Major incident view name here
}
else if(company === "SOME ID"){
answer = 'SOME VIEW NAME';
} else {
answer = "";
}
}
}
})(view, is_list);
View 2:
(function overrideView(view, is_list) {
var isMember = gs.getUser().isMemberOf('HSE TEST');
if(isMember === true){
answer = 'HSE_Incidents';
} else {
answer = null; // set the new view to answer
}
})(view, is_list);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 07:35 AM
Hi,
It's best recommended to merge the code and use 1 view for for the table. Then code appropriately placing whatever should be evaluated first, at the top, and then the next in line, etc.
The same approach would be used for form specific fields and wouldn't apply to list view.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 07:35 AM
Hi,
It's best recommended to merge the code and use 1 view for for the table. Then code appropriately placing whatever should be evaluated first, at the top, and then the next in line, etc.
The same approach would be used for form specific fields and wouldn't apply to list view.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 07:37 AM
Hi
What's the reasoning behind having 2 view rules? I would add the if check from View 2, to View 1 to solve this.
-Mark