- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 11:57 PM
This is my query. In this tracking_no_computer is a variable from a variable set. Now my script returns trckNum= Undefined. How to access this variable in my scheduled job.
Please help.
var queryString ='active=true^short_descriptionLIKE(Refresh)^assignment_group=e8a1b4646f79d90067cf09c54b3ee407';
var sct = new GlideRecord('sc_task');
sct.addEncodedQuery(queryString);
sct.query();
while (sct.next()){
{
var trckNum=sct.variables.tracking_no_computer;
gs.log("This is Fedex info message"+trckNum);
if(trckNum != '')
{
f.track(trckNum);
sct.variables.u_tracking_status_field = f.status;
sct.update();
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 05:05 AM
Hi
As far as I remember the variable is not directly available on the sc_task. You need to create another gliderecord and fetch the requested item, that the task belongs to. Then you can acces the variable through that.
You might also be able to access to through "sct.request_item.variables.u_tracking_status_field"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 05:05 AM
Hi
As far as I remember the variable is not directly available on the sc_task. You need to create another gliderecord and fetch the requested item, that the task belongs to. Then you can acces the variable through that.
You might also be able to access to through "sct.request_item.variables.u_tracking_status_field"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 10:19 PM
Thanks for your reply. But it is not a requested item variable. It is a variable inside a variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 05:56 AM
Hi Maruthu,
That variable is on RITM table and not on sc_task so I updated the code.
"sc_task" has request_item field which refers to RITM table so you need to fetch using that field.
var queryString ='active=true^short_descriptionLIKE(Refresh)^assignment_group=e8a1b4646f79d90067cf09c54b3ee407';
var sct = new GlideRecord('sc_task');
sct.addEncodedQuery(queryString);
sct.query();
while (sct.next()){
{
var trckNum = sct.request_item.variables.tracking_no_computer; // updated the code
gs.log("This is Fedex info message"+trckNum);
if(trckNum != '')
{
f.track(trckNum);
sct.variables.u_tracking_status_field = f.status;
sct.update();
}
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 10:19 PM
Thanks for your reply. But it is not a requested item variable. It is a variable inside a variable set.