- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2019 09:37 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2019 10:45 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 04:12 PM
Hello Chris ,
there are no logs coming out,,
i tried both portal side and regular view
https://xxxdev.service-now.com/nav_to.do?uri=%2Ftask_list.do%3Fsysparm_userpref_module%3D401e902d13d95340602dbcaf3244b04e%26sysparm_view%3DMy_Self-Service%26sysparm_query%3Dopened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe%5EORref_sc_req_item.u_request_item_requested_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe%5EORwatch_listDYNAMIC90d1921e5f510100a9ad2572f2b477fe%5Esys_class_name%3Dincident%5EORsys_class_name%3Dsc_req_item%5EORsys_class_name%3Du_inquiries%5EORsys_class_name%3Dsc_request%5EEQ%26%26sysparm_fixed_query%3Dtrue%26sysparm_clear_stack%3Dtrue
portal URL
https://xxxxdev.service-now.com/its?id=form&table=task&sys_id=1b9d6455dbcb6b40cebc550a4896193c&view=sp
Chris ,, quick question do i need t change the software catalog name and replace sysid?
how exactly catType.indexOf('Software Catalog') this checks?
(function overrideView(view, is_list) {
//get URL details
var url = gs.action.getGlideURI().getMap();
// parse url for information needed
var recSysId = url.get('sys_id');
var isPortal = url.get('portal_id');
// RITM
var ritm = new GlideRecord('sc_req_item');
var state;
var catType;
if(ritm.get(recSysId)){
state = ritm.getDisplayValue('state');
catType = ritm.cat_item.sc_catalogs.getDisplayValue();
}
//A. If the user opening an RITM has no itil roles, and the item is not being opened from a /its portal url, use the ess view
if( !gs.hasRole('itil') && !isPortal ){
view = 'ess';
}
if( !gs.hasRole('itil') && isPortal ){
if(state != 'Closed Incomplete' && catType.indexOf('Software Catalog') > -1){
view = 'sp';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 05:04 PM
For the View Rules, is it set for the sc_req_item table or task because your URL is using task and not the sc_req_item table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 05:15 PM
its set to sc_req_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 05:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2019 05:47 PM
That's fine but your url for portal is using the task table and not sc_req_item
/id=form&table=task&sys_id=.....
Yes, this will render the RITM because RITM is a type of task. However, the View Rules won't kick off because it's looking specifically for the sc_req_item table not task.
So if you want the View Rules to kick off do one of two things:
1) Either change the View Rules to look at task to match the url table=task
Or change your URL to look at sc_req_item
/id=form&table=sc_req_item&sys_id......
Change one or the other not both.