- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 09:00 PM
I created a View Rule to automatically change Views between Portal and internal platform, with the condition like below:
If
- u_application_id is "1"
AND
- Accessed from Service Portal
Then
Apply "u_1_portal" View
Else if
- u_application_id is "1"
AND
- Accessed from internal platform (NOT portal)
Then
Apply "u_1" View
"u_application_id" is the reference field, so I set "sys_id" in the IF condition, but I would like to use "display value" which it's easier to specify the condition value.
Could someone please modify the following script to set condition based on display value of "u_application_id" field instead of sys_id?
(function overrideView(view, is_list) {
//get URL details
var url = gs.action.getGlideURI().getMap();
//Determine if in portal view
var isPortal = url.get('id');
var sys_id = url.get('sys_id');
if(sys_id){
var gr = new GlideRecord('u_shinsei');
if(gr.get(sys_id)){
if(gr.u_application_id == 'sys_id' && isPortal){
answer = 'u_1_portal';
}
if(gr.u_application_id == 'sys_id' && !isPortal ){
answer = 'u_1';
}
}
}else{
answer=null;
}
})(view, is_list);
Best Regards,
Aki
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 11:04 PM
Could you try the below with the getDisplayValue() method?
(function overrideView(view, is_list) {
//get URL details
var url = gs.action.getGlideURI().getMap();
//Determine if in portal view
var isPortal = url.get('id');
var sys_id = url.get('sys_id');
if(sys_id){
var gr = new GlideRecord('u_shinsei');
if(gr.get(sys_id)){
if(gr.getDisplayValue('u_application_id') == 'Give display value' && isPortal){
answer = 'u_1_portal';
}
if(gr.getDisplayValue('u_application_id') == 'Give display value' && !isPortal ){
answer = 'u_1';
}
}
}else{
answer=null;
}
})(view, is_list);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 11:04 PM
Could you try the below with the getDisplayValue() method?
(function overrideView(view, is_list) {
//get URL details
var url = gs.action.getGlideURI().getMap();
//Determine if in portal view
var isPortal = url.get('id');
var sys_id = url.get('sys_id');
if(sys_id){
var gr = new GlideRecord('u_shinsei');
if(gr.get(sys_id)){
if(gr.getDisplayValue('u_application_id') == 'Give display value' && isPortal){
answer = 'u_1_portal';
}
if(gr.getDisplayValue('u_application_id') == 'Give display value' && !isPortal ){
answer = 'u_1';
}
}
}else{
answer=null;
}
})(view, is_list);