Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set my custom created view by default for all the ITIL Users

shaik_irfan
Tera Guru

Hello,

 

I created a View name it as 'ITIL Custom View' which i need to set it as default all the ITIL Users on Incident table. Can anyone please help me out with this 

1 ACCEPTED SOLUTION

try this,

 

(function overrideView(view, is_list) {

	if (gs.hasRole("itil"))	{
		answer = "ITIL_Custom_View"; 
		return answer;
	}
	answer = "ess";
	
})(view, is_list);

 

 

 

 

 

 

 

Beth has ITIL role,

 

View solution in original post

5 REPLIES 5

Shishir Srivast
Mega Sage

This should answer your query: 

Restrict view by role

Shishir,

 

I already tried that below is the script which i written in view rules advanced column:

 

(function overrideView(view, is_list) {

// Add your code here

//Force non-itil users to use the ess view
if (gs.hasRole("itil"))
{return answer;}
if (view.startsWith("ess"))
{return;}
// do not change view if it starts with sys_ (e.g. sys_ref_list)
if (view.startsWith("sys_"))
{return;}
answer = "New V"; // set the new view to answer
//answer = null; // set the new view to answer

})(view, is_list);

 

Am i doing anything wrong, when i impersonate ITIL User i still see Default View

(function overrideView(view, is_list) {

// Add your code here

//Force non-itil users to use the ess view
if (gs.hasRole("itil"))

{

answer = "New V"; 

return answer;

}
if (view.startsWith("ess"))
{return;}
// do not change view if it starts with sys_ (e.g. sys_ref_list)
if (view.startsWith("sys_"))
{return;}
//answer = "New V"; // set the new view to answer
//answer = null; // set the new view to answer

})(view, is_list);

 

This would return that view only if it is itil user. //View Rule

Thanks, I pasted your code when i impersonate i am getting null view 😞

 

 

I am getting for the users like ITIL, Admin role users