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.

utkarsha_s
Kilo Expert

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.

find_real_file.png

Thanks,

Utkarsha Saxena

1 ACCEPTED SOLUTION

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.


View solution in original post

6 REPLIES 6

Uncle Rob
Kilo Patron

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?


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 ?


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.


Hi Robert,



I tried this out and it worked absolutely fine ! Thanks a lot for the quick support Appreciate!



Regards,


Utkarsha