0

I see that the selection is empty when user login for the first time or until a selection is made. Is there a way I can make a default workflow selected from the workflow list on workbox without asking for the user to select for the first time. It works after the user selects a workflow. Please see below screenshot: enter image description here

any advice or suggestions on this.

Thank You

2

The information which workflows are preselected is stored in user profile.

Below is the code of a sample admin page which you can use to set a workflow to be selected when that user opens Workbox.

Just create aspx page in /sitecore/admin folder which uses the code below and then open in your browser

http://YOURDOMAIN/sitecore/admin/setactiveworkflow.aspx?workflowid={A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}&username=sitecore\CHOSEN_USERNAME

I used Sample Worfklow id: {A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}, you can use any other workflow id.

public partial class SetActiveWorkflow : Sitecore.sitecore.admin.AdminPage
{
  protected void Page_Load(object sender, System.EventArgs e)
  {
    CheckSecurity();
    var currentUser = Sitecore.Security.Authentication.AuthenticationManager.GetActiveUser();

    try
    {
      var userName = Request["username"];
      var workflowId = Request["workflowid"];

      if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(workflowId))
      {
        Sitecore.Security.Authentication.AuthenticationManager.SetActiveUser(userName);

        string registryKey = "P" + System.Text.RegularExpressions.Regex.Replace(workflowId, "\\W", string.Empty);
        Sitecore.Web.UI.HtmlControls.Registry.SetString("/Current_User/Panes/" + registryKey, "visible");

        // clearing the cache may not be necessary. just in case
        var shellSiteContext = Sitecore.Sites.SiteContext.GetSite("shell");
        var shellSiteRegistryCache = Sitecore.Caching.CacheManager.GetRegistryCache(shellSiteContext);
        shellSiteRegistryCache.RemoveKeysContaining(Sitecore.Context.GetUserName().ToLowerInvariant());

        Response.Write($"Workflow {workflowId} selected for {Sitecore.Context.GetUserName()}");
      }
    }
    catch (System.Exception exc)
    {
      Sitecore.Diagnostics.Log.Error("Exception while setting active workflow", exc, this);
    }
    finally
    {
      Sitecore.Security.Authentication.AuthenticationManager.SetActiveUser(currentUser);
    }
  }
}
  • 2
    Perhaps an alternative would be to add an SPE Toolbox item that gives you a dialog to make the selection. – Michael West Dec 8 '17 at 23:18
  • @MichaelWest that's a great idea! – Marek Musielak Dec 8 '17 at 23:19
1

If the user who is logging in have any items in his/her workbox, items will be auto populated. But if there are no items on the workbox for the user, you have to manually select the workflow for which you need to see the details.

Also the workflow which was selected when you closed the workbox, will be automatically selected when you open it next time.

  • 1
    thanks Amitabh. But I see that items does not auto populates until user selects a workflow even when there are items awaiting on that user. It forces user to select a workflow to populate. Yes, it saves the selection for the next time but I would like to have selection for the very first time the user login. – shiva Dec 8 '17 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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