Closed krysbzh closed 7 years ago
That hasn't happened to me but I'd like to look into it. Which method are you using in GlideRecord?
On Tue, Feb 16, 2016 at 5:38 AM, krysbzh notifications@github.com wrote:
Hello, I'm currently testing the query method of GlideRecord with a demo ServiceNow instance. The server returns the good list of records but sometimes, I receive randomly a value "undefined". Do you encountered the same behavior ? If I resend the request, I receive again the good values.
Thanks in advance
— Reply to this email directly or view it on GitHub https://github.com/abeyahmad/servicenow-rest/issues/1.
Sorry for the delay. Here you can see my method ` //Get list of records sn.get('/:table_name', function(req, res) { var tableName = req.params.table_name; var gr = new GlideRecord('demo003',tableName,'itil','itil');
console.log(new Date(), 'In hello route GET / req.query=', req.query);
var result;
console.log("START");
//Champs retournes
if(req.query.returnFields != undefined){
gr.setReturnFields(req.query.returnFields);
}else{
gr.setReturnFields('number,short_description');
}
//requete ServiceNow
if(req.query.encodedQuery != undefined){
gr.addEncodedQuery(req.query.encodedQuery);
}else {
gr.addEncodedQuery('active=true');
}
//limite du nombre d'enregistrements
if(req.query.limit != undefined){
gr.setLimit(req.query.limit);
}else{
gr.setLimit(10);
}
gr.query().then(
function(value) {
console.log(value);
res.json(value);
console.log("THE END");
}, function(err) {
console.log(err);
})
}); `
Generally, the result is
req.query=' { limit: '2' } START [ { short_description: 'Unable to get to network file shares', number: 'INC0000002' }, { short_description: 'Wireless access is down in my area', number: 'INC0000003' } ] THE END
but randomly, the results is : req.query=' { limit: '2' } START undefined THE END
Apparently older version of the REST API returns undefined for certains conditions. I fixed the readme to include parameter in constructor to specify version
Hello, I'm currently testing the query method of GlideRecord with a demo ServiceNow instance. The server returns the good list of records but sometimes, I receive randomly a value "undefined". Do you encountered the same behavior ? If I resend the request, I receive again the good values.
Thanks in advance