- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 06:28 AM
Need help please with Business Rule, querying the request table from the sc_task table to see if the parent request has any tasks already open. We need subsequent tasks to detect the other tasks and pick up the same assigned to person.
Of course this isn't working. 😞
var gr = new GlideRecord('sc_task');
gr.addQuery('sys_id',current.request_item.request);
gr.query();
while (gr.next()) {
if(current.request_item.request == gr.request_item.request){
gr.assigned_to = current.assigned_to;
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 10:39 AM
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item.request', current.request_item.request);
gr.query();
while (gr.next()) {
if(gr.assigned_to) {
current.assigned_to = gr.assigned_to;
current.update();
}
}
This will assign the new task to whoever is assigned to other tasks. Is this what you're looking for?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 06:37 AM
If I'm understanding your requirement correctly this code should work. If it's a before business rule, get rid of gr.update():
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.query();
while (gr.next()) {
if(gr.assigned_to){
gr.assigned_to = current.assigned_to;
gr.update()
}
}
Please mark this as correct/helpful if it resolved your issue!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 10:29 AM
Thank you Elijah, I'm trying to query the Request number from the Catalog Task. And if the Task being created have the same request number, then assign those Task to the same technician. 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 10:39 AM
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item.request', current.request_item.request);
gr.query();
while (gr.next()) {
if(gr.assigned_to) {
current.assigned_to = gr.assigned_to;
current.update();
}
}
This will assign the new task to whoever is assigned to other tasks. Is this what you're looking for?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 10:45 AM
You have request field available on the catalog task table. You do not need to dot walk from request item
var gr = new GlideRecord('sc_task');
gr.addQuery('request', current.request);
gr.query();
while (gr.next()) {
if(gr.assigned_to) {
current.assigned_to = gr.assigned_to;
}
}