none
CAML execution sequence RRS feed

  • Question

  • Hi,

    Statement: Feature Staplers fire before any code gets executed from within the ONET. So, if I defined Lists in the <Lists> of ONET and try to manipulate the lists via a feature stapler it fails since the <Lists> section within ONET has executed yet.


    Question:
    What is the sequence of execution in ONET.xml?

    <Configuration ID="0" Name="CustomSiteDef">
        <Lists/>
        <Modules>
            <Module Name="CustomModule" />
        <Modules/>
        <SiteFeatures/>
        <WebFeatures/>
    <Confuguration/>
    <Modules>
        <Module Name="Blank" ..>
        ...
        <Module Name="CustomModule" ...>
    </Modules>

    I beleive the sequence is:
    1. Feature Stapler
    2. <SiteFeatures>
    3. <WebFeatures>
    4. <Lists>
    5. <Modules> in <Configuration> which calls the global <Module>

    Please confirm this is correct.


    Kind regards,
    Kevin
    Wednesday, October 22, 2008 9:44 AM

Answers

  • Update ...

    even more interesting... My Stapled Feature picked up that the TeamCollab feature was also activated!
    This suggests that the onet.xml had begun parsing..

    So .. this is the order that [EDIT - Confirmed]:
    1. <SiteFeatures>
    2. Stapled Site Features
    3. <WebFeatures>
    4. Stapled Web Features
    5. <Lists>
    6. <Modules>


    I will do a slightly more detailed test of this (to confirm 100%), and post the findings on my blog.


    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Wednesday, October 22, 2008 11:23 AM

All replies

  • EDIT - Not actually the correct order ... see other posts below.

    Also .. I have found that staplers will execute from the bottom UPWARDS. So if you have multiple features referenced in a single Stapler, then it will activate the feature at the BOTTOM of the stapler first.

    Given this, if you want to do any list manipulation in your Feature Stapler, then you have a couple of options:

    a) Create your lists through features (either using <ListInstance> or code), and staple the features so they activate before your other stapled features.

    b) Put in some thread.Sleep() statements to your stapled features, and basically "wait" until the lists have been created (probably with a time-out in case you are stuck in an infinite loop)

    I think option (a) is a lot more elegant myself, although you won't be able to apply this to existing site definitions (such as "Team Site", as you can't modify the onet.xml).


    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    • Edited by Martin Hatch Wednesday, October 22, 2008 11:24 AM would have been misleading to other readers to see my post here. See later post, confirming execution order
    Wednesday, October 22, 2008 10:01 AM
  • Ok .. I'm following up and double checking this  .. because on a second read it doesn't make any sense ...

    Why would a Feature Stapler execute BEFORE the onet.xml???
    surely it makes far more sense for stapled Features to execute LAST!

    There should be nothing in the onet.xml that relies on a stapled feature (otherwise it would be in the onet.xml itself). And executing last allows access to everything in the site (lists / pages / everything).

    I'm testing this as we speak, and will get back to you.


    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Wednesday, October 22, 2008 10:54 AM
  • Yep ... correct the first time ...

    a Feature Stapler DOES execute before the onet.xml.

    I ran a simple stapled event handler...

    Web.Lists.Count = 1 (Master Page Gallery)
    Web.Files.Count = 0

    So "<Lists>" has not been hit yet .. and neither has "<Modules>" .. but interestingly enough GLOBAL has (hence the Master Page gallery being there).

    (note .. I stapled to "STS#0" and not GLOBAL).
    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Wednesday, October 22, 2008 11:12 AM
  • Update ...

    even more interesting... My Stapled Feature picked up that the TeamCollab feature was also activated!
    This suggests that the onet.xml had begun parsing..

    So .. this is the order that [EDIT - Confirmed]:
    1. <SiteFeatures>
    2. Stapled Site Features
    3. <WebFeatures>
    4. Stapled Web Features
    5. <Lists>
    6. <Modules>


    I will do a slightly more detailed test of this (to confirm 100%), and post the findings on my blog.


    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Wednesday, October 22, 2008 11:23 AM
  • After (reasonably) extensive testing .. the results are in .. and confirm what I thought (so no new surpises)

    Full details on my blog here, along with step-by-step walkthrough of what I found.
    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Wednesday, October 22, 2008 12:31 PM
  • Thanks Martin.
    Wednesday, October 22, 2008 1:50 PM