
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:03 AM
Hi Guys,
I want to put an if condition with glide record script on the workflow that creates GTASKs (child tasks) of a GREQ when complexity is medium or complex checking the number of GTASKs if it is 0 or not. I want to query the u_incident_task table to through a glide record to check the number of GTASKs on the parent GREQ form and if it is 0 then go ahead to create the child in the workflow else end the workflow.
I need the script to do this, please let me know what would be the exact script.
Thanks,
Utkarsha Saxena
Solved! Go to Solution.
- Labels:
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:48 AM
var gtsks = new GlideRecord('gtask table');
gtsks.addQuery('parent',current.sys_id); //this assumes that your GTasks are linked to your GREQ's via the parent field
gtsks.query();
if (gtsks.next()){
answer = true;
} else {
answer = false;
}
Embed that code in an If statement activity and you should be ok.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:31 AM
So... there are pre-existing GTasks that are already attached to the GREQ? If they pre-exist, end the workflow. If there are none, proceed to build the 3 tasks pictured?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:37 AM
Yes Robert, I need to check if they exist end the workflow else proceed to create them. What is the script that I should write ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 08:48 AM
var gtsks = new GlideRecord('gtask table');
gtsks.addQuery('parent',current.sys_id); //this assumes that your GTasks are linked to your GREQ's via the parent field
gtsks.query();
if (gtsks.next()){
answer = true;
} else {
answer = false;
}
Embed that code in an If statement activity and you should be ok.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 09:42 AM
Hi Robert,
I tried this out and it worked absolutely fine ! Thanks a lot for the quick support Appreciate!
Regards,
Utkarsha