Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Wednesday, July 13, 2016

Solved : Unable to see any items in Sitecore workbox



I was working on Sitecore workflow task. Certainly one of the newly client-side reviewer started complaining that he is unable to see items in his workbox?

I started investigation on this but unable to find any clue that why items are not visible to that particular reviewer?

For the time being I provided him admin rights and try to login from his account. Now he is able to view items in workflow approval section.

But reviewer can’t become admin. So where was the actual problem?

Solution:
If you are unable to see any item in workbox, but at the same time admin can view the items in workbox it means you don’t have permissions on items.

Assign read/write permissions from Access Viewer -> Assign Security Rights to that user/reviewer on all required items.

 

If any user can’t take any action on content tree items then Sitecore not shows any of those items in workbox as well.

Hope this pointer will help somebody who is in similar situation.

Please leave your comments or share this trick if it’s useful for you.

Friday, April 24, 2015

How to create Page Not Found in Sitecore

In every Sitecore application, if end user type some page name that is not exist then we need to redirect user to some custom page which inform user that requested page is not available.

Here are the steps for it.

·         Create template, layout and content item for Page not found.
·         Write below code in your project

namespace MyProject.CodeFiles
{
    /// <summary>
    /// 404 class
    /// </summary>
    public class Page404Resolver : Sitecore.Pipelines.HttpRequest.HttpRequestProcessor
    {
        public override void Process(Sitecore.Pipelines.HttpRequest.HttpRequestArgs args)
        {
            if (Sitecore.Context.Item != null || Sitecore.Context.Site == null || Sitecore.Context.Database == null)
            {
                return;
            }

            // If current item not available in Sitecore, then
            if (Sitecore.Context.Item == null)
            {
                Sitecore.Diagnostics.Log.Info("Page404Resolver=" + System.Web.HttpContext.Current.Request.Url, this);

                // Find an error-page item and set it to context Item
                Item item404 = args.GetItem(new ID("{XXXXX1D2-8CDB-4461-93CE-501905DDSSSS}"));
                if (item404 != null)
                {
                    Sitecore.Context.Item = item404;
                    Sitecore.Context.Items["is404"] = "true";
                    Sitecore.Diagnostics.Log.Info("CUSTOM ERROR HANDLER: 404 :  Item is not null - Setting Context item to 404 page", this);
                }
            }
        }
    }
}


·         Open web.config file and add this class just below ItemResolver line of pipeline section

<processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel"/>
<processor type="MyProject.Web.Present.CodeFiles.Page404Resolver, MyProject.Web.UI"/>

·         Implement below code in page load section of File Not Found page. Keep response status as 404 and also set status of response.

    public partial class NotFound : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                if (Sitecore.Context.Items["is404"].Equals("true"))
                {
                    try
                    {
                        Response.StatusCode = 404;
                        Response.TrySkipIisCustomErrors = true;
                        Response.StatusDescription = "File not found";
                        //Response.End();
                    }
                    catch (Exception ex)
                    {
                        // Log error
                    }
                }
            }
        }

Please leave your comments or share this code if it’s useful for you.