Copied to clipboard

Flag this post as spam?

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


  • Hendrik Jan 71 posts 137 karma points
    Nov 15, 2011 @ 14:45
    Hendrik Jan
    0

    Deeper nodes (SortChildrenByDateProperty ex)

    [Error]

    I get the following error having the main folder at level/depth 3, and creating a new item.
    ( only when creating new items the error occurs )

    " DateFolders SortChildrenByDateProperty exception "

    The exeption is just a side effect btw. 


    [Structure]
    1. site
       2. home
       2. page
         3. Datefolder main
            4.  month
                5.  year
                    6. items
       2. page

    [Structure adding item]

    1. site
       2. home
       2. page
         3. Datefolder main
            4.  month
                5.  year
                    6. items
       2. year
          3. month
             4. year
                5.  month 
                    6.  new added item
      2. page

     

    [ Quick fix ]

    Check in the Document_AfterSave if the parents are correct. After save is not needed on new items :)

    ====


    The Document_New handler works fine. But the Document_AfterSave handler is creating the error.

    I saw that the parentId was wrong so i added a check 

    void Document_AfterSave(Document doc, SaveEventArgs e)
    {
    ...
    ...
    Document parent, monthFolder, yearFolder, monthDoc = null, yearDoc = null;
    monthFolder = new Document(doc.ParentId);
    yearFolder = new Document(monthFolder.ParentId);
    parent = new Document(yearFolder.ParentId);
    // >> check if the monthfolder is of the datefolder type. If not, stop 
    if( !_dateFolderDocType.Equals( monthFolder.ContentType.Alias ) 
       || !_dateFolderDocType.Equals( yearFolder.ContentType.Alias )  ) return;
    ...
    ...
    }

     

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies