We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Is there a way to query the ECC queue payload and get a value from it?

Ajai S Nair
Giga Guru

Hi All,

For one of my automation item I need to query some table from a SAP system and evaluate some value of a field. Now I got a sample script from concerned team for this. But after querying it will echo the value. If so can we get that value from ECC queue payload based on the variable inside it ?

6 REPLIES 6

Not applicable

Hi Ajai,



Good Day



Please find the below script to retrieve the value of the payload.



Var eccRecord = new GlideREcord('ecc_queue');  


eccRecord.addQuery('sys_created_on','ONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)');


eccRecord.addQuery('queue','input');


eccRecord.addQuery('topic','SAP');


eccRecord.query();


while(eccRecord.addQuery()){


var payload = eccRecord.payLoad;


gs.print('The Payload is'+payload);


}



Thanks,


Priyanka R


Mukesh Sharma
Kilo Guru

Do it this way . 

 

var grQue=new GlideRecord('ecc_queue');
grQue.addQuery('sys_id','443660881b51c4d00d5221be6e4bcb15');
grQue.query();
if(grQue.next())
{
var text =grQue.payload+'';
var xmlhelp = new XMLHelper(text);
var x = xmlhelp.toObject();
gs.print("tag is: " + x.result.stdout);
}