none
task hierarchy in one field RRS feed

  • Question

  • hi

    i need a field in MSP 2010 to show task hierarchy.

    For example in picture below:

    for task "7" i need a field like this: "6 - 8 - 9 - 7".

    Could anyone help me in this?

    Monday, September 19, 2011 7:41 AM

Answers

  • Hi,

    I'm afraid you need VBA for that. If I gave you the code could you implement the procedure?

    This is how it goes if there are exactly 3 levels:

    Sub ForShadi

    dim Job as task

    For each job in activeproject.tasks

    if not job is nothing then

    ifjob.outlinelevel=3 then

    job.text1=job.outlineparent.outlineparent.name & " - " & job.outlineparent.name & " - " & job.name

    end if

    end if

    next job

    end sub

    Greetings!

    • Marked as answer by Shadi Movahed Monday, September 19, 2011 2:38 PM
    Monday, September 19, 2011 1:42 PM
    Moderator
  • Sbodgi, I am so sorry :(

    You should delete that line. I am using that line for another field...

    So, you shpuld run this macro:

    Dim tsk As Task
    Dim i As Integer
    For Each tsk In ActiveProject.Tasks
        i = tsk.OutlineLevel
            If Not tsk Is Nothing Then
                While i > 0
                    tsk.TaskHierarchy = tsk.OutlineParent.TaskHierarchy & " - " & tsk.Name
                    i = i - 1
                Wend
            End If
    Next tsk

    End Sub

     

    let me know if it helped.

    • Marked as answer by Shadi Movahed Wednesday, February 29, 2012 2:12 PM
    Wednesday, January 25, 2012 4:56 AM

All replies

  • Hi,

    Are you talking about the hiarchy numbers? Then Right click -> Insert WBS it gives numeric sequencing with hiarchy, if not please provide details if you are looking at Task Name? Is it a kind of report you are trying to pull or what?


    Sapna S
    Monday, September 19, 2011 7:50 AM
    Moderator
  • Thanks Sapna for your reply.

    I need to have a report in MSP for some selected tasks. I have set a flag for these tasks. But i need a field to show the Hierarchy of each Tasks.

    Fore Example in this picture:

    I need a field that shows this for WorkItem 2: "Package1 - Task 1 - WorkItem 2"

    Monday, September 19, 2011 1:33 PM
  • Hi,

    I'm afraid you need VBA for that. If I gave you the code could you implement the procedure?

    This is how it goes if there are exactly 3 levels:

    Sub ForShadi

    dim Job as task

    For each job in activeproject.tasks

    if not job is nothing then

    ifjob.outlinelevel=3 then

    job.text1=job.outlineparent.outlineparent.name & " - " & job.outlineparent.name & " - " & job.name

    end if

    end if

    next job

    end sub

    Greetings!

    • Marked as answer by Shadi Movahed Monday, September 19, 2011 2:38 PM
    Monday, September 19, 2011 1:42 PM
    Moderator
  • Thank Jan.

    it was worked only for 2 levels.

    I have changed it:

    Sub TaskHierarchy()


    Dim Job As Task
    Dim jal As Integer
    For Each Job In ActiveProject.Tasks
        jal = Job.OutlineLevel
            If Not Job Is Nothing Then
                While jal > 0
                    Job.Text20 = Job.OutlineParent.Text20 & " - " & Job.Name
                    jal = jal - 1
                Wend
            End If
    Next Job

    End Sub

    Monday, September 19, 2011 2:37 PM
  • Can i achieve somehow such hierarchy in PWA Timesheet view? Using VBA or something else?
    • Edited by MSPUser Wednesday, January 18, 2012 3:24 PM
    Wednesday, January 18, 2012 3:24 PM
  • hi

    you can do this:

    1- add a new custom field in server setting (Name: taskHierarchy, entity:task, type: text)

    2- run this macro in your projects and save your project:

    Sub Task_Hierarchy()

    Dim tsk As Task
    Dim i As Integer
    For Each tsk In ActiveProject.Tasks
        i = tsk.OutlineLevel
            If Not tsk Is Nothing Then
                While i > 0
                    tsk.TaskHierarchy = tsk.OutlineParent.TaskHierarchy & " - " & tsk.Name
                    i = i - 1
                Wend
            End If
        tsk.TaskSystemName = tsk.projectSystemName
    Next tsk

    End Sub

    3- add "TaskHierarchy" in your Timesheet view...


    Saturday, January 21, 2012 10:09 AM
  • i cannot run this macro.

    becouse of this error:

     

    Monday, January 23, 2012 9:32 AM
  • Sbodgi, I am so sorry :(

    You should delete that line. I am using that line for another field...

    So, you shpuld run this macro:

    Dim tsk As Task
    Dim i As Integer
    For Each tsk In ActiveProject.Tasks
        i = tsk.OutlineLevel
            If Not tsk Is Nothing Then
                While i > 0
                    tsk.TaskHierarchy = tsk.OutlineParent.TaskHierarchy & " - " & tsk.Name
                    i = i - 1
                Wend
            End If
    Next tsk

    End Sub

     

    let me know if it helped.

    • Marked as answer by Shadi Movahed Wednesday, February 29, 2012 2:12 PM
    Wednesday, January 25, 2012 4:56 AM