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

Chaitanya ILCR
Kilo Patron

HI @sukran ,

Try this script

var grp = gs.getProperty('testing_update').split(',');
var url = gs.action.getGlideURI().toString(); // get URL of the record
gs.addInfoMessage(url);
for (var i = 0; i < grp.length; i++) {
    if (url.includes(grp[i])) { // check URL contains property sys id
        current.addInactiveQuery();
        return;
    }
}
current.addActiveQuery();

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @sukran ,

have you tried this script?

does it work?

if it works and is helpful could you please accept this as a solution too? as you can accept multiple responses as solutions

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @Chaitanya ILCR 

I tried using script and function gs.action.getGlideURL method , but the output is not as expected 

and mainly in the service portal its not working 

 

I tried below script as well but its working for platform view not in service portal

var query = gs.getUrlOnStack();
if (query) {

if(!query.includes(xxx)){
current.addActiveQuery();
}

 

VikMach
Mega Sage

You can simply fetch the sys_id of the current record using below syntax. 

var sysID = RP.getParameterValue('sys_id');

 Why creating System Property for simple URL query?