
- 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 10:35 AM
More importantly... do you understand how/why it works?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 09:45 PM
Yes Robert I do understand how this one is working, actually I had written something similar but it didn't work.. also in your script I had to twist the true and false section and then it worked.
var inc = new GlideRecord('u_incident_task');
inc.addActiveQuery();
inc.addQuery('parent.number','current.sys_id');
inc.addAggregate('','parent.number');
inc.query();
var gtasks = 0;
if(inc.next())
{
gtasks = inc.getAggregate('COUNT');
}
if(gtasks > 3)
{
return 0;
}
This wasn't working though yours worked fine.
Thanks again!
Utkarsha