Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jo Kendal 32 posts 194 karma points
    Aug 21, 2018 @ 11:55
    Jo Kendal
    0

    PublishWithChildrenWithStatus

    Urgent code question - issue.

    I am hoping someone can perhaps shed light as I am needing to resolve ASAP.

    When copying a node with child nodes in program code. Then publishing all with children is OK if the date time for release is straight away.

    However when I schedule the release date of the top level node then the top level node gets published at release date - but NONE of the children have published status.

    I have tried variations:

    contentService.PublishWithChildrenWithStatus(newNode,0,true);
    
    contentService.PublishWithChildrenWithStatus(newNode, includeUnpublished:true);
    

    Then tried adding in the following too as a belt and braces approach

    foreach (var node in newNode.Descendants())
    {
    node.ReleaseDate = exerciseStartDateTime; contentService.SaveAndPublishWithStatus(node);
    }
    

    All of these variants copy the node and children fine - but if the release date of the top level node is set to a future date then when that date comes round the children are not published.

  • Jo Kendal 32 posts 194 karma points
    Sep 06, 2018 @ 13:52
    Jo Kendal
    100

    Issue resolved. The problem was this.

    If the top level node was saved with a forward release date then publishing the children shows failure in the status collection.

    For my purposes then - I save the node without a release date, then publish all the descendants, then set a release date on the parent node and then save the node again.

    When the release date comes around the parent and all children do now become available.

    //get a copy of the site node I want to use to create a new site
    var newNode = contentService.Copy(nodeToCopy, [xxx ParentID xxx], false);
    
    //save the node (with all it's children)
    contentService.Save(newNode);
    
    //method below is strictly speaking named incorrectly - because it doesn't just publish children it publishes all descendants
    var result = contentService.PublishWithChildrenWithStatus(newNode, includeUnpublished: true);
    
    //now set the release date and re-save
    newNode.ReleaseDate = [xxx FutureDate xxx];
    contentService.Save(newNode);
    
Please Sign in or register to post replies

Write your reply to:

Draft