1

Created a custom processor to execute translation during publish process:

<processor type="Sitecore.Publishing.Pipelines.PublishItem.CheckSecurity, Sitecore.Kernel" 
<processor type="Feature.Translation.Commands.TranslateOnPublish,Banner.Feature.Translation" 
<processor type="Sitecore.Publishing.Pipelines.PublishItem.DetermineAction, Sitecore.Kernel"  

while working on the class which is inheriting PublishItemProcessor is returning the value of Sitecore.Context.Database null.

1 Answer 1

3

You should not use Sitecore.Context.Database in any backend job. It may be null there, or sometimes core, or sometimes master if you start some job manually.

You should use your item.Database property instead, e.g.:

public class CustomPublishProcessor : PublishItemProcessor
{
    public override void Process(PublishItemContext context)
    {
        try
        {
            Item sourceItem = context.PublishHelper.GetSourceItem(context.ItemId);
            var database = sourceItem.Database;
1
  • I am trying to use context.PublishHelper.GetTargetItemInLanguage(item.ID, Sitecore.Globalization.Language.Parse(DestLanguage)); but this is coming null always @Marek Musielak Commented Jun 9, 2022 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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