none
PublishedTask.Parent is always uninitialized RRS feed

  • Question

  • The PublishedTask.Parent property is always uninitialized.  It is never null.  It is never filled in with values.  (See image below.)

    I am trying to use this property to get the summary task of a published task.  Is this the correct purpose?  (The docs describe this property poorly.)  In other words, for any given task I'd like to know the summary task that is above it in the hierarchy.  Or in other words... if a task is indented, I want the outdented parent above it.  Make sense?

    If PublishedTask.Parent does not return the summary task above a task, how do you get it?

    ProjContext.Load(PublishedProject.Tasks);
    ProjContext.ExecuteQuery();
    
    foreach (PublishedTask Task in PublishedProject.Tasks)
    {    
        Console.WriteLine(Task.Parent.Id);
    }

    Uninitialized parent.



    ScoutwestInc

    Tuesday, September 22, 2015 3:16 PM

All replies

  • CSOM doesn't work that way, you need to say CSOM which data it has to load.

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Parent))

    should work.


    Wednesday, September 23, 2015 7:46 AM
  • Thanks for the quick reply!

    But this doesn't seem to work.  Here are my results after doing this:

    1. None of the properties in Task.Parent are initialized
    2. None of the properties in Task are initialized
    3. I cannot refer to Task.Id without throwing an exception
    4. I cannot refer to Task.Parent.Id without throwing an exception

    I would rather have a way to fill in all the task properties.  I don't want any of them to be uninitialized.  I want them all.

    Is there a way to load all the properties, including the Parent?

    Or, is there a way to get the parent Id without throwing an exception?


    ScoutwestInc

    Wednesday, September 23, 2015 4:06 PM
  • Yes, you need to load all properties you want manually, CSOM is build up on request, you get only that what you have requested. So if you do not query it you get these values uninitialized. I do not know a way where you say something like LoadAllProperties() method. And I think this isn't the way how it should work.
    Thursday, September 24, 2015 7:28 AM
  • Okay, so how do you load each property manually?

    When I tried your method above, it threw an exception when trying to access Task.Parent.Id.  How do I load Task.Parent.Id?

    Honestly, all I want is the parent id of a task.  But I don't know how to load that property.

    Here is what I tried:

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Parent))

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Parent.Id))

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Id))

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Parent), t => t.Include(pt => pt.Id))

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Parent), t => t.Include(pt => pt.Parent.Id))

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Id, pt => pt.Parent))

    ProjContext.Load(PublishedProject.Tasks, t => t.Include(pt => pt.Id, pt => pt.Parent, pt => pt.Parent.Id))

    Task.Retrieve("Parent");

    ProjContext.Load(Task);

    ProjContext.Load(Task.Parent);

    And a bunch of crazy combinations of all these.  None worked.  I can get all the other properties except Parent and Parent.Id.  I cannot get those without throwing an exception.

     

    I don't know the secret combination to load the parent id of a task.


    ScoutwestInc





    • Edited by ScoutwestInc Wednesday, September 30, 2015 5:57 PM Added more things I tried
    Thursday, September 24, 2015 11:51 AM
  • Are there any other ways to get the parent Id for a task?

    Or is there a way to escalate this to Microsoft for more assistance?


    ScoutwestInc

    Tuesday, September 29, 2015 11:49 AM
  • This is old.  I am still looking for a combination that works.  Anybody get further with this?

    Thank you!

    Wednesday, June 19, 2019 2:54 PM