none
Determine a sub-task's level using SharePoint Designer?

    Question

  • Greetings, all!

    I have a task list in a SP2013 site that includes tasks nested 4 to 5 levels deep, as in:

    Task Level 1

          Sub-Task Level 2

             Sub-Sub-Task Level 3

             Another Sub-Sub-Task Level 3

          Another Sub-Task Level 2

    Another Task Level 1

    The client has given me a display requirement that necessitates my being able to identify and filter tasks based on each task's "level" in the hierarchy/outline. I haven't found a web UI-accessible column that identifies the outline level, so my next stop is SPD workflow. Through workflow, I can grab a column called "Level," but so far it only seems to return a string value of "1" for every task, regardless of how deeply they're nested.

    Due to client requirements, I'm trying to achieve this through workflow rather than writing any deeper custom code or app.

    Any suggestions? Is this even possible?

    Thanks in advance!

    Wednesday, September 28, 2016 8:31 PM

Answers

  • Hi Wendy,

    Thanks for the confirmation!

    For the benefit of anyone who might stumble onto this question down the road, I ended up leveraging the fact that a task at the top level of a task list hierarchy doesn't have a Parent ID to return, to determine the current task's level using a nested If/Else hack:

    Essentially, the logic goes like this:

    1. If the current item has no parent ID, then it gets assigned to level "0"
    2. Otherwise, check the Parent ID of the returned Parent ID.
    3. If the Parent ID task has no Parent ID, then current task gets assigned to level "1"
    4. Otherwise, check the Parent ID of the returned Parent ID of the returned Parent ID
    5. Repeat to the anticipated levels of the task list in question.

    It's kludge-y...but worked quite well in this particular case.

    Thanks again!

    --Eric

    • Marked as answer by eculver3 Friday, September 30, 2016 3:12 PM
    Friday, September 30, 2016 3:12 PM

All replies

  • Hi eculver3,

    In SharePoint 2013 UI, there is not a column which could show the task's level.

    When we open the tasks list using SharePoint Designer and create a workflow, we can find there is a column called "Parent ID". If a task is a top level task(first level), when we log the column, it will show empty. If a task is a subtask, it will show the ID of the parent task. So, you can use the column to identify whether a task is a subtask or not.

    However, per my knowledge, there is no a direct way to identify the level of a subtask. If you want to identify the level of the task, you need to use code to do that.

    Thanks,

    Wendy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by eculver3 Friday, September 30, 2016 12:44 AM
    • Unmarked as answer by eculver3 Friday, September 30, 2016 3:12 PM
    Thursday, September 29, 2016 8:50 AM
    Moderator
  • Hi Wendy,

    Thanks for the confirmation!

    For the benefit of anyone who might stumble onto this question down the road, I ended up leveraging the fact that a task at the top level of a task list hierarchy doesn't have a Parent ID to return, to determine the current task's level using a nested If/Else hack:

    Essentially, the logic goes like this:

    1. If the current item has no parent ID, then it gets assigned to level "0"
    2. Otherwise, check the Parent ID of the returned Parent ID.
    3. If the Parent ID task has no Parent ID, then current task gets assigned to level "1"
    4. Otherwise, check the Parent ID of the returned Parent ID of the returned Parent ID
    5. Repeat to the anticipated levels of the task list in question.

    It's kludge-y...but worked quite well in this particular case.

    Thanks again!

    --Eric

    • Marked as answer by eculver3 Friday, September 30, 2016 3:12 PM
    Friday, September 30, 2016 3:12 PM