System properties to check indexOf certains catalog item?

sukran
Mega Sage

How to call system properties when I have 3 catalog item sys IDs and that needs to check whether it match to current catalog item sys id 

 

Below is the query BR

 

var grp = gs.getProperty('testing_update').split(',');
var url = GlideTransaction.get().getRequest().getHeader("referer");  // get URL of the record
gs.addInfoMessage(url);
if (url.indexOf(grp) > -1) {   // check URL contains property sys id
    current.addQuery('active' , 'false');
}else{
    current.addActiveQuery();
}
1 ACCEPTED SOLUTION

sunnyt1
Tera Expert

Hi @sukran ,

 

You can try this script.

var grp = gs.getProperty('testing_update').split(',');

// get sys_id of the current record
var sysId = RP.getParameterValue('sys_id');
for(var i=0;i<grp.length;i++){
     if(grp[i]===sysId){
          current.addInactiveQuery();
          return;
     }
}
current.addActiveQuery();

View solution in original post

8 REPLIES 8

 We have few catalog items that should allow inactive users to be select and those catalog items sys id mapped in the property

and the requirement is the current catalog item is match to those catalog items ,then it should allow else restrict to choose inactive users

I didn't understand your requirement fully.
Could you elaborate properly? It looks like the approach you are taking is making your system more complex.
My questions are as follows.
 inactive users - Where and how are inactive users even accessing Catalog Items from? It doesn't make any sense to me.
Explain your requirement so that correct solution can be provided.

sunnyt1
Tera Expert

Hi @sukran ,

 

You can try this script.

var grp = gs.getProperty('testing_update').split(',');

// get sys_id of the current record
var sysId = RP.getParameterValue('sys_id');
for(var i=0;i<grp.length;i++){
     if(grp[i]===sysId){
          current.addInactiveQuery();
          return;
     }
}
current.addActiveQuery();

It works

Appreciated your brillance