Filter list of record with a business rule

xif1
Mega Expert

Hi Service now community

 

I've tried to filter a list of record with a business rule,

 

Below a piece of my code :

 

FiltrerTrade();


function FiltrerTrade()
{
   gs.log("launch BS /////");
   var cUser = gs.getUser(); 
   if (cUser.isMemberOf('dab52fb36ff9e100089542750d3ee4b4') == true)
   {
   gs.log('member of Trade');
   var grp = new GlideRecord('u_gtb_reclam');
   grp.addEncodedQuery('assignment_group=dab52fb36ff9e100089542750d3ee4b4^ORu_first_assigment_group=dab52fb36ff9e100089542750d3ee4b4');
   grp.query();
   while (grp.next())
   {
   if (grp.assignment_group = 'dab52fb36ff9e100089542750d3ee4b4' || grp.u_first_assigment_group == 'dab52fb36ff9e100089542750d3ee4b4')
   {
   gs.log('can read ' + grp.number);
   }
   }
   }
}

 

This BS work find and return what I want, like "member of Trade & can read NB0001", so That find the good record.

But now I try to filter my list and I don't know how to do, i've already try to return a filter, but doesn't work.

Actually after this BS, all of my record are shown, I just want to display NB001.

 

Thanks in advance for your answers !

1 ACCEPTED SOLUTION

marcguy
ServiceNow Employee

in the BR you have


WHEN: query true


table: u_gtb_reclam


you then add to the current query by scripting current.addQuery...



i.e.


var qc = current.addQuery('assignment_group','dab52fb36ff9e100089542750d3ee4b4').addOrCondition('u_first_assigment_group','dab52fb36ff9e100089542750d3ee4b4');


View solution in original post

5 REPLIES 5

marcguy
ServiceNow Employee

in the BR you have


WHEN: query true


table: u_gtb_reclam


you then add to the current query by scripting current.addQuery...



i.e.


var qc = current.addQuery('assignment_group','dab52fb36ff9e100089542750d3ee4b4').addOrCondition('u_first_assigment_group','dab52fb36ff9e100089542750d3ee4b4');


It works perfectly with



return (current.addQuery('assignment_group','dab52fb36ff9e100089542750d3ee4b4').addOrCondition('u_first_assigment_group','dab52fb36ff9e100089542750d3ee4b'));

it works fine but only with equal value.



i.e : if I use '=', or 'CONTAINS' or 'LIKE' it works perfectly but if I use '!=' or 'DOES NOT CONTAINS' or 'NOT LIKE'


it fail...



Any idea ?


marcguy
ServiceNow Employee

if you remove the 's' from DOES NOT CONTAINS does it work 'DOES NOT CONTAIN'