Service Portal widget: unable to fetch data from table

suresh91
Tera Guru

Hi All,

In my widget server script need to fetch the data from table. For that, I have run the simple code like below

My server script:

 

var gr2 = new GlideRecord('incident');
gr2.addQuery('number','INC00012345');
gr2.query();
gs.info("---------");
while(gr2.next())
gs.info("---------1111"+gr2.getValue('number'));

 

In the logs, unable to see the number details. I can see it is not going to inside while condition (Incident is present in backend). I have run the same code in the background script, it's working fine and showing details in logs.

 

Could you please let me know what is the issue and how to fetch the details from table using server script in Widget?

1 ACCEPTED SOLUTION

suresh91
Tera Guru

I have tested there are some restriction on widget for that it was not showing ticket widget. I have fixed it and working fine.

View solution in original post

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron

Hi you need to do like below,

var inc = new GlideRecord("incident");
inc.addQuery("number", "INC0010057");
inc.query();
while (inc.next()) {
var a = {};
$sp.getRecordValues(a, inc, 'short_description,number,caller,assignment_group');


console.log("INC short desc= "+a.short_description);
console.log("INC number= "+a.number);

}

Regards
Harish

Hi @Harish KM ,

 

Thanks for your reply.

 

I have tried the above scenario or code, but still not fetching data and not printing any logs as well. It seems fetching data from table using glide record in widget server script is not working. Do you have any idea why it is not working? need to do any changes in table level or anywhere?

suresh91
Tera Guru

I have tested there are some restriction on widget for that it was not showing ticket widget. I have fixed it and working fine.