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.

Force view based on logged in user

Andre8
Giga Guru

Hello,

I would like to show a specific view for the user viewing a record and IS NOT the assigned to person:

I have created a view rule but for some reason the view is not being forced.

 

Andre8_0-1689781086254.png

 

1 ACCEPTED SOLUTION

I was able to add javascript to the condition to display the correct view. Thanks!

 

Andre8_0-1689786664686.png

 

View solution in original post

2 REPLIES 2

Arun_S1
Tera Guru
Tera Guru

@Andre8 Please try this, I wanted to show the default view to admin and Self Service View to other users, below is the view rule I have written.

(function overrideView(view, is_list) {

	// Add your code here
	answer = null;  // set the new view to answer
	var user=gs.getUserName();
	if(user=='admin'){
		answer='default';
	}else{
		answer='ess';
	}

})(view, is_list);

 

Please mark the appropriate response as correct answer and helpful.

Thanks!!

I was able to add javascript to the condition to display the correct view. Thanks!

 

Andre8_0-1689786664686.png