How to change incident form view based on user role and on change in form fields?

priya119
Kilo Explorer

Hi,

I want to change the incident form view based on the role of user, severity and particular assignment group entered on incident form.
I can not use view rule, as there is no scripting space in view rule to check desired role of user. I want similar functionality as "view rule" where on change of severity, group and based on user role form view should be changed.
Using client script, I tried to use switchview() method on submit of incident form for form section of incident table but observed that it changes the list view and not the existing form view. For all the existing incident records which matches to the conditions I'm not able to see the changed view.
Also, not able to use out-of-box global business rule - "incident functions", this BR changes the view for the first time but on change of severity and assignment group it doesn't change to desired view. Can you please suggest how to change form view based on user role with changes in incident fields?

Thanks,
Priya J

3 REPLIES 3

Mark Stanger
Giga Sage

This article sums it up pretty well. It sounds like you'll probably have to run the 'switchView' function in an onLoad client script.

http://www.servicenowguru.com/scripting/client-scripts-scripting/change-form-view-client-script


Hi



In Incident Form — when i select the View User= 'Abraham Lincoln ' it should activate " Emergency view"


except "Abraham Lincoln "     if i selected any other user name or put empty it should activate " Default view"



when i open record-if View user='Abraham Lincoln ' —       form should be in " Emergency View"


when i open record-if View user=' ' —         form should be in " Default View"




how can i write script OnLoad & OnChange???




My script is : OnLoad is not working


Onchange:




if(!isLoading){


if(newValue != "){


if(newValue == 'a8f98bb0eb32010045e1a5115206fe3a'){


switchView('section','incident','Emergency');


}


}


if(newValue != 'a8f98bb0eb32010045e1a5115206fe3a'){


switchView('section','incident','Default');


}




}


}




OnLoad:


function onLoad() {




var strView = document.getElementById('sysparm_view').value;


var strid=g_form.getDisplayBox(' u_view_users').value;


if(strView == 'Emergency' && strid!=' a8f98bb0eb32010045e1a5115206fe3a')){


switchView('section','incident',' ');


}


}


abhijats
Tera Expert

This is helpful!