advanced view rules

RudhraKAM
Tera Guru

can we use both condition and check the logged in users role in the advanced view rules ?

as we cannot use the current element in the view rules 

how do we check condition (where open RITM is from software catalog ) and logged in user has itil role then go to ess view.

 

can some one help me with this 

1 ACCEPTED SOLUTION

ChrisBurks
Mega Sage

If you need to check the user's role then you have to use the advanced script. In your other post I showed how to get both with an advanced script:

https://community.servicenow.com/community?id=community_question&sys_id=63545a6bdbbe6700d6a102d5ca961937

But also from your other post you mention to check against a Portal page as well. The view rules won't work if you're viewing a record using a "ticket" page because the ticket page doesn't direct pull in the "form" directly. Although, you can set the "view" it can use via the url it's pulling that from the url and then setting that view in the server script. 
Viewing a record with the "form" page is made more in line with the platform view and will execute view rules. Thus in order to use the actual "view rules" setup with portal you'll need to view the RITM using the form page or a page using the form widget.

View solution in original post

17 REPLIES 17

sachin_namjoshi
Kilo Patron
Kilo Patron

Use below for view rules since current object won't work in view rules advanced script.

 

var url = gs.action.getGlideURI().getMap();

 

var sysId = url.get('sys_id');

 

 

 

 

 

var gr = new GlideRecord('change_request');

 

if (gs.getUser().getRecord().getValue('u_type') == '10') {

 

 

 

 

 

answer = 'portal';

 

 

 

}else{

 

 

 

if (gr.get(sysId)) {

 

 

 

if (gr.type == '0') {

 

 

 

answer = '';

 

}else if(gr.type == '1'){

 

 

 

answer = 'emergencyChange';

 

 

 

}

 

}

 

}

 

Regards,

Sachin

sachin_namjoshi
Kilo Patron
Kilo Patron

Use below since current object is not available in advanced view rules.

 

var url = gs.action.getGlideURI().getMap();


var sysId = url.get('sys_id');




var gr = new GlideRecord('change_request');


if (gs.getUser().getRecord().getValue('u_type') == '10') {




answer = 'portal';



}else{



if (gr.get(sysId)) {



if (gr.type == '0') {



answer = '';


}else if(gr.type == '1'){



answer = 'emergencyChange';



}


}


}

Hello Sachin

I already tried that its not working