Joel's SharePoint Architecture Blog

SharePoint Server, SharePoint Online and Office 365 Training, Architecture, Administration and Development

  • Home
    • Sitemap
  • #SPThingADay
  • Articles
    • SharePoint Online
      • SharePoint Online – Drag and Drop and Large File Uploads
    • SharePoint 2016
    • SharePoint 2013
      • Content Database Changes to the AllUserData Table
    • SharePoint 2010
      • Administration
        • Disable CRL Checking
        • Excel 2010 & PowerPivot
        • Limits & Thresholds
        • PeoplePicker AD Errors
        • Recycle Bin Behaviour
        • Renaming a Server
        • Service Pack 1
        • Unattended Installs
        • Uninstall All SharePoint 2010 Solutions via PowerShell
        • User Alert Management
        • Virtualised SharePoint
        • Visio Stencils for Administrators
      • Development
        • Audience Membership Workflow Activity
        • Base Types, Lists & Content Types
        • BCS & Offline Sync
        • Debugger Skipping Lines
        • Development Laptop Spec
        • Enabling JavaScript IntelliSense
        • Event Receivers & Deployment Jobs
        • FavIcons & SPUrl
        • Google Maps Sandbox Web Part
        • Group By Content Type for List Views
        • Locale Stapler / Master or Default Locale
        • Removing Default Editor Parts
        • Sandbox Embedding Resources
        • Solution Sandbox Introduction
        • SPPersistedObject
        • Restoring Deleted SPSites in SP1
        • SPWebConfigModification 1
        • SPWebConfigModification 2
        • STSADM copyappbincontent vs. Install-SPApplicationContent
        • Workflows for Beginners
        • Workflow InitiationData Seralizer
    • SharePoint 2007
      • Alternate Access Mappings
      • Excel Services
      • Excel Services UDFs & Excel Client 2007
      • Experiences from the Field
      • InfoPath & Forms Server
      • Kerberos & SSRS
      • Records Management
      • Web Application Service
      • WSS vs MOSS
  • Training
    • SharePoint Admin Links
  • Downloads
    • Summary Slides for PowerPoint
    • CodePlex Projects
      • Audience Membership Workflow Activity
      • Google Maps Sandbox Web Part
      • Group By Content Type in List Views
      • Locale Stapler / Master or Default Locale
      • SharePoint Outlook Connector
  • Hire Me!
    • MCP Transcript
    • Résumé/CV
  • PostsComments
You are here: Home / SharePoint / Event Receivers and Content Deployment Jobs

Event Receivers and Content Deployment Jobs

November 23, 2010 by Joel Jeffery 4 Comments

SharePoint 2010 has many wonderful improvements over previous versions. One of which is a vastly improved Content Deployment mechanism and API.

If your application makes use of Event Receivers or Feature Receivers, these can, depending upon what they do, cause problems during a Content Deployment job. If you have code that you’d rather not execute when your event is triggered as a side effect of a Content Deployment job, you can use the SPImportContext object to find out if a job is running, and if so, to take alternative action.

Here’s an example on an ItemAdding Event Receiver (you’ll also need a using statement referring to the Microsoft.SharePoint.Deployment namespace)

   1: /// <summary>

   2: /// An item is being added.

   3: /// </summary>

   4: public override void ItemAdding(SPItemEventProperties properties)

   5: {

   6:     if (!SPImportContext.Current.IsRunning)

   7:     {

   8:         //TODO: add event receiver code here

   9:         base.ItemAdding(properties);

  10:     }

  11: }

If you miss this out this check in an Event Receiver or Feature Receiver, you might cause deadlocks or spurious List Items that you did not intend.

Share this:

  • Share
  • Twitter
  • Facebook
  • LinkedIn
  • Reddit
  • Print
  • Email

Filed Under: SharePoint Tagged With: Development, SharePoint 2010, SharePoint Architecture, SharePoint Developer

Comments

  1. Kazim says

    June 7, 2012 at 19:33

    Hi Joel,

    I have to use the same code for MOSS and 2010 , that is clients requirement.

    Now if i use ImageUrl in CustomActionGroup , wsp for moss would not be deployed because ImageUrl in CustomActionGroup will break the schema. Client want’s to have ImageUrl for 2010 and without that for MOSS. So is there any way through which ‘during deployment’ i can figure out which feature to deploy and which to ignore ?.

    I can create two features one with imageUrl and one without now its matter of ignoring one after getting the “12” or “14”.

  2. Maninder says

    March 19, 2014 at 07:10

    Hi ,
    I would be great help if you could guide me through the following situation .

    I am using content deployment Job and the target of content deployment job is having an event receiver on a specific list that moves items to another site collection(Added,Updated,Deleted).
    Everything works fine when i am adding manually event receiver is working fine. But when content deployment job is migrating content .event receiver is not firing ,can u please share your views on the same .

    Thanks in advance.

  3. Joel Jeffery says

    March 19, 2014 at 17:14

    Hi Marinder!

    I assume you’re using the Content Deployment API to run your job. By design SharePoint will not execute any asynchronous “after” events during an import. If you really want to enable this, you need to set the SuppressAfterEvents property on the SPImportSettings object to false.

    Hope this helps!

    joel

  4. Maninder says

    April 16, 2014 at 10:05

    Hi Joel Thanks for your reply , Can you please guide me through the following situations ,i am managed to solve the previous issue regarding event firing using STSADM command: STSADM -o editcontentdeploymentpath -pathname Interaktor-Replication-Path -enableeventreceivers yes

    After this event starts firing ItemAdded events works fine but on itemUpdated when i am trying to get Properties.listItem i am getting strange results .The list for listitem is not my list on which it should fir event e.g Images list i am able to get a list name as “Fast Buffer Profiles” .So this is breaking the whole functinality.

    It would be a great help for any comments on the same.
    Thanks in Advance

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Joel is a full-stack cloud architect who codes. He is a Microsoft Certified SharePoint 2016, SharePoint Online and Azure specialist and Microsoft Certified Trainer.
He has over 17 years' experience with SharePoint and the Microsoft .NET Framework.
He's also Director at Microsoft Gold Partner JFDI Consulting Ltd. Read More…

#SPThingADay

Load More…

Recent Posts

  • SharePoint Thing a Day – 073 – SharePoint Information Architecture. Content Type Hub Gotchas
  • SharePoint Thing a Day – 072 – SharePoint Information Architecture. The Content Type Hub
  • SharePoint Thing a Day – 071 – SharePoint Information Architecture. Content Type Management Options.
  • SharePoint Thing a Day – 070 – SharePoint Search. Result Types and Display Templates.
  • SharePoint Thing a Day – 069 – SharePoint Search. Crawl Rules vs Crawler Impact Rules.
Joel's Acclaim Profile
Joel's Microsoft Profile

Tags

Administration Architecture Certification Cloud Development Information Architecture intranets MCP Microsoft Microsoft Architecture Microsoft Azure migration Mobile Development MOSS MOSS 2007 office365 Office 365 Office 365 PowerShell SaaS SharePoint SharePoint 2010 SharePoint 2010 Training SharePoint 2013 SharePoint Administration SharePoint Administrator SharePoint Architecture SharePoint Designer 2010 SharePoint Developer SharePoint Development sharepointonline SharePoint Online SharePoint Search SharePoint Training SharePoint Videos Silverlight SOA Solution Sandbox SPThingADay TechEd 2007 Training Videos Visual Studio 2010 Windows Phone 7 WSS
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright © 2019 Joel Jeffery, SharePoint Architect

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.