Wait for Condition

stevenm
Kilo Guru

I have a very large request from a customer to create dozens of tasks.  I've built it off of a database, reading that table in order to create and attach all of the tasks.  I then have a Wait for Condition script that waits for all of those tasks to complete.  However, if I check multiple tasks and use the drop down to Close them all at once something, somewhere, is creating a bunch of new, duplicate, tasks.  I put a timer in my workflow to see if this happens before the wait for condition ever occurs.  It seems to only happen after that wait for condition is called. 

 

See attachments.  In taskcount you can see I start with 128 tasks.  I then do a multiple close (before5min and before5minpart2) the count is the same.  Then I try a multiple close after the timer (after5min and after5minpart2). You can see the task count has gone from 128 to 200.  My script, which I probably found on-line, is also attached.

 

I haven't seen any business rules that would do something like this.

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Your issue is likely the Branch activity, or rather the two paths leading from it.  The Branch activity itself doesn't do anything other than visually draw attention to more than one path.  You could also have two paths leading from the Notification activity.  In any event, the lower path is creating specific tasks, waiting 20 seconds, then creating more tasks...  The upper path is Creating a Catalog Task, then - after this task is closed, or immediately depending on the task setting - also running the same scripts to create specific tasks, wait, then create more tasks again.  You can have the Catalog Task and the first script run in parallel, just don't do anything after the Catalog Task activity, or lead into a Join activity that leads to the Wait for condition activity with the 5 minute timer also leading into the Join activity, or you could probably lead the Catalog Task into the Wait for condition with the same result.

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

The wait for script itself is fine.  It will run every time the RITM record is updated, which also happens when a related Catalog Task is closed/inactive.  What does the entire workflow look like?  How are you creating the 128 Catalog Tasks?

stevenm
Kilo Guru

Here is the large chunk of the script I'm using.  It reads a custom table and then writes all these tasks.  

 

var grStories = new GlideRecord("u_stories_for_enhancements");

if (current.variables.type_of_dept == 'Inpatient') {

    grStories.addEncodedQuery("u_active=true^u_catalog_item=17b675cb1bb996106^u_criteria1=InpatientSelection");

    grStories.query();

} else if (current.variables.type_of_dept == 'Emergency') {

    grStories.addEncodedQuery("u_active=true^u_catalog_item=17b675cb1bb996106^u_criteria1=EmergencySelection");

    grStories.query();

} else if (current.variables.type_of_dept == 'Hospital Outpatient') {

    grStories.addEncodedQuery("u_active=true^u_catalog_item=17b675cb1bb996106^u_criteria1=OutpatientSelection");

    grStories.query();

} else {

    grStories.addEncodedQuery("u_active=true^u_catalog_item=17b675cb1bb996106^u_criteria1=RuralSelection");

    grStories.query();

}

 

while (grStories.next()) {

    var gc = new GlideRecord("sc_task");

    gc.initialize;

    gc.request_item = current.sys_id;

    gc.correlation_id = 'KetteringHealthNewDept';

    gc.description = workflow.scratchpad.longdesc;

    gc.short_description = grStories.u_story_short_description;

    gc.assignment_group = grStories.u_story_assignment_group;

    gc.cmdb_ci = workflow.scratchpad.cmdb_ci; // epic security

    if (grStories.u_story_acceptance_criteria == 'Build in POC/TST Due Date')

    {

        gc.due_date = epicbuildDate;

    }

    else if (grStories.u_story_acceptance_criteria == 'Application build in POC/TST Due Date')

    {

        gc.due_date = downstreamDate;

    }

    else if (grStories.u_story_acceptance_criteria == 'MRT Testing Date')

    {

        gc.due_date = mrtDate;

    }

    else if (grStories.u_story_acceptance_criteria == 'Integrated Testing Due Date')

    {

        gc.due_date = integratedtestDate;

    }

    else if (grStories.u_story_acceptance_criteria == 'Build in PRD/Production Due Date')

    {

        gc.due_date = isbuildDate;

    }

    else if (grStories.u_story_acceptance_criteria == 'System Validation Date')

    {

        gc.due_date = systemsvalidationDate;

    }

    else

    {

        gc.due_date = firstpatientDate;

    }

    var newtaskid = gc.insert();

}

Brad Bowman
Kilo Patron
Kilo Patron

Your issue is likely the Branch activity, or rather the two paths leading from it.  The Branch activity itself doesn't do anything other than visually draw attention to more than one path.  You could also have two paths leading from the Notification activity.  In any event, the lower path is creating specific tasks, waiting 20 seconds, then creating more tasks...  The upper path is Creating a Catalog Task, then - after this task is closed, or immediately depending on the task setting - also running the same scripts to create specific tasks, wait, then create more tasks again.  You can have the Catalog Task and the first script run in parallel, just don't do anything after the Catalog Task activity, or lead into a Join activity that leads to the Wait for condition activity with the 5 minute timer also leading into the Join activity, or you could probably lead the Catalog Task into the Wait for condition with the same result.

stevenm
Kilo Guru

Oh my, how did I miss that.  I am a little embarrassed.  Let me fix that and see what happens.