Encoded Query

VinayKumarA
Tera Contributor

Hi All,

 

 We have an encoded query which is being run under a function of script include for an integration. We can copy the encoded query from table but is there any possibility to check the result of that encoded query in service now table. Below is the query referencing to sc_task table.

 

var taskNum = new GlideRecord('sc_task');   
        taskNum.addEncodedQuery('number=' + current.u_clientitemnumber + '^request_item.cat_itemIN' + gs.getProperty('List of Catalog item') + '^active=true');
 
Appreciate the quick response and help.
1 ACCEPTED SOLUTION

Najmuddin Mohd
Mega Sage

HI @VinayKumarA 
You can add a log message in the script.


var taskNum = new GlideRecord('sc_task');   
       taskNum.addEncodedQuery('number=' + current.u_clientitemnumber + '^request_item.cat_itemIN' + gs.getProperty('List of Catalog item') + '^active=true');
taskNum.query();

while(taskNum.next()){
gs.log("Task: " + taskNum.number + "\n");
}


If this is not suitable, then you can hard code the u_clientitemnumber and run the query in the Scripts background.
For example, u_clientitemnumber is SCTASK0001, then

From Navigate to Scripts - background and run the query.

var taskNum = new GlideRecord('sc_task');   
       taskNum.addEncodedQuery('number=' + 'SCTASK0001' + '^request_item.cat_itemIN' + gs.getProperty('List of Catalog item') + '^active=true');
taskNum.query();

while(taskNum.next()){
gs.log("Task: " + taskNum.number + "\n");
}


If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

View solution in original post

1 REPLY 1

Najmuddin Mohd
Mega Sage

HI @VinayKumarA 
You can add a log message in the script.


var taskNum = new GlideRecord('sc_task');   
       taskNum.addEncodedQuery('number=' + current.u_clientitemnumber + '^request_item.cat_itemIN' + gs.getProperty('List of Catalog item') + '^active=true');
taskNum.query();

while(taskNum.next()){
gs.log("Task: " + taskNum.number + "\n");
}


If this is not suitable, then you can hard code the u_clientitemnumber and run the query in the Scripts background.
For example, u_clientitemnumber is SCTASK0001, then

From Navigate to Scripts - background and run the query.

var taskNum = new GlideRecord('sc_task');   
       taskNum.addEncodedQuery('number=' + 'SCTASK0001' + '^request_item.cat_itemIN' + gs.getProperty('List of Catalog item') + '^active=true');
taskNum.query();

while(taskNum.next()){
gs.log("Task: " + taskNum.number + "\n");
}


If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.