Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a custom web template where I activate the webfeature "Group Work Lists". I have also a event receiver where I would like to do some logic. I try to get the splist item of one of my group work lists, for example the list "links". But I cannot find it in the website. So my eventreceiver is triggered to fast. After the the site is created, I can see the group work lists are available.

Is there some trick or method how I can fix this problem? I would like that my group work list instances are available before the feature eventreceiver is triggered?

Here is my webfeature section of my onet xml:

 <WebFeatures>

    <!--GroupWork   Group Work Lists    9c03e124-eef7-4dc6-b5eb-86ccd207cb87-->
    <Feature ID="9c03e124-eef7-4dc6-b5eb-86ccd207cb87"></Feature>

    <!-- Include the common WSSListTemplateFeatures used by CMS -->
    <Feature ID="00BFEA71-DE22-43B2-A848-C05709900100" > </Feature>
    <Feature ID="00BFEA71-E717-4E80-AA17-D0C71B360101" > </Feature>
    <Feature ID="00BFEA71-52D4-45B3-B544-B1C71B620109" > </Feature>
    <Feature ID="00BFEA71-A83E-497E-9BA0-7A5C597D0107" > </Feature>
    <Feature ID="00BFEA71-4EA5-48D4-A4AD-305CF7030140" > </Feature>
    <Feature ID="00BFEA71-F600-43F6-A895-40C0DE7B0117" > </Feature>
    <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"> </Feature>

    <!-- Publishing -->
    <Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="ChromeMasterUrl" Value=""/>
        <Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/default.aspx"/>
        <Property Key="PagesListUrl" Value=""/>
        <Property Key="AvailableWebTemplates" Value=""/>
        <Property Key="AvailablePageLayouts" Value=""/>
        <Property Key="SimplePublishing" Value="true" />
      </Properties>
    </Feature>
    <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
      <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
        <Property Key="InheritGlobalNavigation" Value="true"/>
        <Property Key="ShowSiblings" Value="true"/>
        <Property Key="IncludeSubSites" Value="true"/>
      </Properties>
    </Feature>
    <Feature ID="94C94CA6-B32F-4da9-A9E3-1F3D343D7ECB">
      <!-- Office SharePoint Server Publishing -->
    </Feature>

    <!-- the eventreceiver where I am talkin about is inside this faeture-->
    <Feature ID="f262bb46-6155-440b-b236-14cf89902341"></Feature>
  </WebFeatures>

Here is my eventreceiver where I would like to do some logic on the links list:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb web = properties.Feature.Parent as SPWeb;
SPlist splist = web.Lists["Links"];
}

It returns null. I have also add a breakpoint at this point of the lifecycle and check in powershell if the list is available. Is not available at this moment. The list is available later in the lifecycle.

UPDATE: the eventreceiver where I am talking about is not on the feature where the onet.xml is comming from. It is the eventreceiver of another feature. The following faeture which I activate it in my webfeature elements:

share|improve this question
add comment

1 Answer

I suggest to have feature dependency on the "Group Work Lists" feature from your event receiver feature. So that, your event receiver will be triggered only after the lists are created.

share|improve this answer
    
I try that, but it is not working because: The feature of my custom web template is site scoped and the other feature is web scoped. –  KHA Mar 29 '13 at 12:24
    
That doesn't matter I think. You can have Feature dependency from a web scoped feature to site scoped feature. Example: Sub site Publishing feature is dependent on Site Collection level Publishing Infrastructure feature. –  BHUMI Mar 29 '13 at 12:31
    
In my situation, it is from a site scope to a web scope. And thats not supported. –  KHA Apr 1 '13 at 18:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.