need help with Script include

Renu4
Tera Contributor

Hello All,

i have a script include in which i would like to add 3 groups in the condition but not sure how to do it .need some help.

The script is:

   if (!gs.getUser().hasRole('ABS_EXT_FTS'))
        {result += '^name!=EXT_FTS' ;}
        return result + '^ORDERBYDESCu_order';
    },
I want to change the result line where the groups can be multiple like below.;
 
   if (!gs.getUser().hasRole('ABS_EXT_FTS'))
        {result += '^name!=EXT_FTS' ; || '^name!=EXT_FTS_NW' ; || '^name!=EXT_FTS_Storage' ; }
        return result + '^ORDERBYDESCu_order';
    },
 
How do i achieve it.
1 ACCEPTED SOLUTION

if (gs.getUser().hasRole('itil')) {
    result += '^nameINEXT_FTS,EXT_FTS_NW,EXT_FTS_Storage'; 
}
else if(gs.getUser().hasRole('ABS_EXT_FTS')){
result += '^name!=EXT_FTS^name!=EXT_FTS_NW^name!=EXT_FTS_Storage'; 
}


return result + '^ORDERBYDESCu_order';

View solution in original post

5 REPLIES 5

-O-
Kilo Patron
Kilo Patron

You are not specifying a very important detail: what should the query express: that the groups "selected" should be one of those 3 or that the groups "selected" should be none of those 3?

Renu4
Tera Contributor

Well what i want to achieve is :people with Role ABS_EXT_FTS should be able to view the 3 groups.

ie

EXT_FTS

EXT_FTS_NW

EXT_FTS_Storage.

People with itil role should not be able to see these 3 groups.

The script include works for just one group.But as you can see i need to hide 3 groups.

if (gs.getUser().hasRole('itil')) {
    result += '^nameINEXT_FTS,EXT_FTS_NW,EXT_FTS_Storage'; 
}
else if(gs.getUser().hasRole('ABS_EXT_FTS')){
result += '^name!=EXT_FTS^name!=EXT_FTS_NW^name!=EXT_FTS_Storage'; 
}


return result + '^ORDERBYDESCu_order';

Brad Bowman
Kilo Patron
Kilo Patron

It looks like you are intending to return an encoded query.  When you are specifying that something is not equal to more than one thing, you must logically always join them with an AND - as using OR will always make the condition false because it's always not equal to one of those - so try changing your script to:

 

if (!gs.getUser().hasRole('ABS_EXT_FTS')) {
    result += '^name!=EXT_FTS^name!=EXT_FTS_NW^name!=EXT_FTS_Storage'; 
}
return result + '^ORDERBYDESCu_order';