Maksym Ponomarenko
Sitecore Consulting

How to fix Sharepoint Synchronization Problems in Sitecore


In Sitecore 8.1, if you find that some Sharepoint Document Items present on CM (Content Management environment) and missing on CD (Content Delivery), check if you have a warning message in the logs on CM:

WARN SitecoreItemCrawler : Update : Latest version not found for item sitecore://web/{Sharepoint_Document_ID}?lang=en&ver=1. Skipping

Usually it happens when you use “onPublishEndAsynk” strategy for indexing and don’t disable default publish settings in the /App_config/Sitecore.config, so the incremental publishing runs asynchronously each 10 seconds.

<!-- Agent to publish database periodically -->
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:00:10">
<param desc="source database">master</param>
<param desc="target database">web</param>
<param desc="mode (full or smart or incremental)">incremental</param>
<param desc="languages">en, da</param>
</agent>

The warning message is recorded by the SitecoreItemCrawler, when it tries to get the latest version of a Sharepoint Document Item.

Database.GetItem(indexable.Item.ID, language, Sitecore.Data.Version.Latest)

So theoretically the publish agent publishes some items just after the Sharepoint Connector creates them without any version.

If you run a smart publish, all missing Sharepoint Document items will be published and reindexed. But then you can face the problem again after the importing new Sharepoint Documents.


How to fix it:

  • disable the PublishAgent in the Sitecore config
  • create an additional process in the “createIntegrationItem”, “updateIntegrationItem” and “deleteIntegrationItem” pipelines to publish Sharepoint


Code example:

public static void PublishItem(Item item)
{
// The publishOptions determine the source and target database,
// the publish mode and language, and the publish date
Sitecore.Publishing.PublishOptions publishOptions =
new Sitecore.Publishing.PublishOptions(item.Database,
Database.GetDatabase("web"),
Sitecore.Publishing.PublishMode.Smart,
item.Language,
DateTime.Now); // Create a publisher with the publishoptions
Sitecore.Publishing.Publisher publisher = new Sitecore.Publishing.Publisher(publishOptions);

// Choose where to publish from
publisher.Options.RootItem = item;

// Publish children as well?
publisher.Options.Deep = false;
FanucLog.Debug("Publish of item '{0}' started".FormatWith(item.ID));
// Do the publish!
publisher.Publish();
}

Also you don’t need to publish an Item, if it wasn’t modified:

var field = args.IntegrationItem.Fields["__Modified"];
var itemModified = DateUtil.ToServerTime(new DateField(field).DateTime);
var sharepointModified = DateUtil.ToServerTime(Convert.ToDateTime
(documentItem["ows_Modified"]).ToUniversalTime());
var modified = itemModified != sharePointModified;

I used Sitecore 8.1 and SPIF 2.1

Kommentare
Es wurden noch keine Kommentare zu diesem Eintrag geschrieben.
Kommentar hinzufügen
Vor und Zuname
E-Mail
E-Mail bei weiteren Kommentaren
Mein Kommentar