0
I am trying to setup a way to display the progress of items/tasks. The way that the tasks are setup is that they have sub-tasks and parent tasks.

I have a field in the state form which shows the progress percent of the task in a field. What I would like to do is if the task in question has no sub-tasks, then to have its progress be determined by its state (new,design/coding,validation,closed). However if the task does have sub-tasks, then its progress is based on the mean average of the progresses of its children.

The way that I am setting the field values right now is via a JavaScript which runs when the form is loaded. However, the problem I'm having is that this only updates the current task, and does not propagate to its parent, unless I load it.

For example, lets say I have three tasks: Parent_1, Sub_1, Sub_2. Initially all the tasks are at 0%. If I change the state of Sub_1 to design/coding, it becomes 25% completed. However, Parent_1 remains at 0% instead of 12.5%.

This makes it hard to track project progress.

Is there some way that I could accomplish this?
Responses (3)
  • Accepted Answer

    Sunday, June 18 2017, 05:20 PM - #Permalink
    0
    I can think of a couple possible ways to do this, depending on how comfortable you are with AppScript, or if your environment supports it.


    Approach #1. Create an AppScript that will be run on every transition for all item types. The script finds the "top level parent" for the current item. The current item may be the top level parent. It then iterates through all descendants of that parent, counting the number of descendants and adding up their completion status (based on their State). Along the way it can set each item's completion status field. After iterating all descendants, it calculates the top-level parent's "completion status" (total completion status / count of descendants) and saves this value in the parent's record. The parent will always contain it's current completion status value as a percentage of the number of children and their cumulative completion statuses.


    Approach #2. Whenever a child item is created, have it's SUBMIT transition do a transition action on the parent to run a "quick" transition that increments a "number of descendants" counter. Whenever a child item transitions through the workflow, it will do an action on the parent to cause the parent to run a "quick" transition to add some value to the "cumulative completion status" value. That transition (by the parent) then triggers another transition on itself to calculate the percentage completion status value. Alternatively you could forget the last transition action and have a report that displays the result of a calculation. The downside being that you need to run the report to see the parent's percentage completion status.
    This approach uses transition actions to perform some of the functions of the AppScript. It's less flexible but has the benefit of no scripts which become maintenance challenges.


    If you go with approach #1 I'd suggest eventually creating an aux table containing State "Internal Names" and a numeric completion status. This will allow you flexibility if you add, remove or rename States. Instead of hard-coding "design/coding" State means "25%", you would lookup the subtask's Internal State name "MY_APP.DESIGN_CODING" in the aux table, find the related value 25 and use that. You'll need to maintain the aux table when changing the workflow, but not the script.
    The reply is currently minimized Show
  • Accepted Answer

    Monday, June 19 2017, 03:15 PM - #Permalink
    0
    Thanks for your reply Paul.

    How would I go about finding the "top level parent" for the current item.
    Is there a way to access all the items in the process app, and then go through them all, seeing which one is a parent and which is not?

    I am still new to AppScript and any help would be appreciated.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, June 20 2017, 12:28 PM - #Permalink
    0
    Ilia Poretski wrote:
    How would I go about finding the "top level parent" for the current item.


    Learning AppScript takes a lot of reading (Script and DB Schema Guides) and experimenting. You could also take the SBM courses that cover scripting and save yourself and your company a lot of time and money.

    Make sure that in the POST or SUBTASK transitions settings (in the "Options" tab) you use a multi-relational field in the "Set new item in original item's field" and a single-relational field in the "Set original item in new item's field". This gives you an easy way for an AppScript to find an item's "parent" or "children". I don't know how "deep" your object hierarchy is. I'll assume 2 levels. The AppScript gets the value of the field specified in "Set original item in new item's field". If this is 0 then the current item is the the top level item, otherwise the current item is the "child" and that field contains the TS_ID of the top level item.

    It you are using different Issue Types for "parent" and "child" item types then you could also check that, but looking at the relational fields would probably be easier.



    Ilia Poretski wrote:
    Is there a way to access all the items in the process app, and then go through them all, seeing which one is a parent and which is not?


    Create an AppRecordList object, do a ReadWithWhere("ts_id>0") call which will populate the AppRecordList object with all valid items in the table, then iterate the table using a "For Each" loop. See the scripting guide for the exact syntax.

    It's probably not what you want to do ... you'll find a lot of parents and a lot of children.
    The reply is currently minimized Show
Your Reply

Recent Tweets