0

I have a custom menu written to copy the item language version to another language.

The current behavior is - when I click on the menu it copies the current language version to another language version and don't reload or refresh the item. I have to re-click on the item to reload or refresh it. I want to trigger this by code so I wrote the code as below

     var copiedItem = _db.GetItem(item.ID, _targetLanguage);
            string load = string.Concat("item:load(id=", copiedItem.ID, ",language=", copiedItem.Language, ",version=", copiedItem.Version, ")");
            Context.ClientPage.SendMessage(this, load);

But I am getting the error as below -

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Sitecore.Web.UI.Sheer.ClientPage..ctor() at Sitecore.Context.get_ClientPage() at PT.Framework.ItemCopy.Copying.CopyFromLanguage.AddVersionRecursiveCommand.StartProgressBar(Object[] contextParameters)

What I understood so far is that I cannot refresh the ClientPage from a custom command class. but then there should be some solution, right? if yes, then please help me to resolve this (it's already taken my half a day)

Thank you to all in advance.

2
  • Did you investigate the Context.ClientPage.ClientResponse Namespace? Commented Jun 18, 2019 at 9:45
  • Yes, It is Sitecore.Web.UI.Sheer , is it correct? I think this is the issue then, right?
    – Sanjay
    Commented Jun 18, 2019 at 10:08

1 Answer 1

0

Please try the Timer method with refresh option,

String refresh = String.Format("item:refreshchildren(id={0})", myItem.Parent.ID); Sitecore.Context.ClientPage.ClientResponse.Timer(refresh, 2);

1
  • string refresh = string.Format("item:refresh(id={0})", args.Parameters["id"]); //worked when I use "item:refresh" instead off "item:refreshchildren". Thanks @Nizar
    – Sanjay
    Commented Jul 30, 2019 at 11:41

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.