Try our conversational search powered by Generative AI!

Workaround for Recycle Bin items for EPiServer Connect for SharePoint

Product version:

EPiServer Connect for Sharepoint 2007 version 2.1

Document version:

1.0

Document last saved:

14-01-2009

Introduction

This technical note document describes how to use EPiServer Connect for Microsoft SharePoint 2.1 solution to function optimally.

Requirements

• A functioning SharePoint (WSS or MOSS) Web server.
• A Web server running EPiServer CMS 5 R2

Configuration

The configuration file of the Web site should be set to correct values. Configuration is described in the EPiServer Connect for Microsoft SharePoint  2.1 Installation Instructions.

Handling Known Issues

An issue with updating items on SharePoint side which are deleted on EPiServer CMS Web site

There is an issue when updating items on the SharePoint side. If a corresponding page for the item was deleted on the EPiServer CMS Web site then the user will get an exception page.

Complete the following steps in order to resolve this issue and see the code example below.

  1. Create a special page type for the corresponding SharePoint item type. For example, all announcements coming from SharePoint should go into a SharePoint Announcement page type. If you do not want to create a separate page type thenyou should use a specific property for existing page types. The main idea is to separate pages which are updated by the SharePoint side from pages that are not.
  2. Create an event handler Global.asax file of the EPiServer CMS Web site project for the DataFactory class DeletedPage event.
  3. When this event is triggered, you should look for a specific page type or a specific property on the page that has been created (as in step 1).
  4. If it is true (the page type or the property matches) then you should (hard) delete the page so it does not exist in EPiServer CMS Web site.

    The idea is that the Pages are moved to the Recycle Bin. Pages created with the SharePoint connector re-use the same GUID as they have in SharePoint, therefore a SharePoint item can only exist in the EPiServer CMS Web site as one page. If the page is moved to the Recycle bin the connector will not be allowed to create it again and also not be able to move it from the Recycle bin.

    See the code example below:

    protected void Application_Start(Object sender, EventArgs e)
    {
        //TODO: Add your code here
        DataFactory.Instance.MovedPage += new PageEventHandler(DataFactory_MovedPage);
        //TODO: Add your code here
    }

    void DataFactory_MovedPage(object sender, PageEventArgs e)
    {
        // check e.PageLink though should never be
        //  null or empty in this event
        if (!PageReference.IsNullOrEmpty(e.PageLink))
        {
    // e.Page is null in this event, we need to load the
    // PageData via e.PageLink to be able to check
    //  it's PageTypeID
            PageData page = DataFactory.Instance.GetPage(e.PageLink);  
    // value of this property below
    //  should probably be read from configuration
            int pageTypeIdIAmInterestedIn = 4;

            if (e.TargetLink.ID == EPiServer.Configuration.Settings.
                Instance.PageWastebasketId &&
                page.PageTypeID == pageTypeIdIAmInterestedIn)
            {
                DataFactory.Instance.Delete(e.PageLink,
                true, EPiServer.Security.AccessLevel.NoAccess);
            }
        }
    }