- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 05:57 AM
Hi community,
I need to get the sys_ID task from a new request item. Can you help me please
(The task is create by a workflow)
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 08:32 AM
You are getting the request sys_id not requested item. Here is your updated script. Try this
gs.include('Cart');
var cart= new global.Cart();
var item=cart.addItem('put in the sys_id of catalog item');
var rc= cart.placeOrder();
var reqID=rc.getValue('sys_id');
var body={};
var scTaskID='';
var scTask= new GlideRecord('sc_task');
scTask.addQuery('request',reqID);
scTask.query();
while(scTask.next()){
if(scTaskID.length >0){
scTaskID+=scTask.getValue('sys_id')+',';
}
else{
scTaskID=scTask.getValue('sys_id');
}
}
body.name=scTaskID;
}
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 06:10 AM
Hi Raphael,
Are you doing this in a business rule? If so, what table are you working with?
Suffice it to say, if you've got the sys_id of the requested item (sc_req_item) record, I'll assume via a business rule on that table, then you can find any/all tasks that have that request item as a parent.
var scTask = new GlideRecord('sc_task');
scTask.addQuery('parent', current.getValue('sys_id'));
scTask.query();
while (scTask.next()) {
// Do what you need with the returned records
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 08:06 AM
hi ctomasi,
Nice to meet you (i seen some video with you )
I'm doing this in a Script rest resource. And i'm sure your solution is good but it's not working for the moment i try this but it return error
{
"error": {
"message": "The undefined value has no properties.",
"detail": "ConversionError: The undefined value has no properties. (<refname>; line 56)"
},
"status": "failure"
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 08:32 AM
You are getting the request sys_id not requested item. Here is your updated script. Try this
gs.include('Cart');
var cart= new global.Cart();
var item=cart.addItem('put in the sys_id of catalog item');
var rc= cart.placeOrder();
var reqID=rc.getValue('sys_id');
var body={};
var scTaskID='';
var scTask= new GlideRecord('sc_task');
scTask.addQuery('request',reqID);
scTask.query();
while(scTask.next()){
if(scTaskID.length >0){
scTaskID+=scTask.getValue('sys_id')+',';
}
else{
scTaskID=scTask.getValue('sys_id');
}
}
body.name=scTaskID;
}
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 08:56 AM
What else ? your answer is perfect !
Thanks you Abhinay and thanks everybody !