LibrarySites.Banner

Initiating server operations via PXM InDesign client

One of the common PXM requests is the ability to initiate operations on the Sitecore server from within the InDesign client. This would commonly do things such as initiating a workflow or a new version on a content item while within InDesign.

There are two ways in order to accomplish this;

1 – Tasks

Tasks have the advantage of being able to pass an alert back to the InDesign client. However they have to be initiated manually, often in conjunction with having to select the item in which you want to initiate the task on.

Creating a task is very much like creating a custom renderer. You need to create the code, reference the code and finally define how that reference will appear within the InDesign client interface.

Step 1 – Code example

This is very minimal code, the purpose of which is merely to alert back to InDesign a list of variables that are passed to the task. As well, in this case it increments the version of the item that was selected.

using Sitecore.Data.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace LaunchSitecore.pxm.tasks
{
    public class RenderContent
    {
        public string ExecuteTask(Dictionary<string, object> dictionary)
        {
            string result = string.Empty;
            if (dictionary != null)
            {
                foreach (KeyValuePair<string, object> k in dictionary)
                {
                    result += " key: " + k.Key + " value: " + k.Value + " ";
                }
            }
 
            string itemid = dictionary["ci_contentBrowser"].ToString();
 
            Item contentItem = Sitecore.Context.Database.GetItem(itemid);
 
            contentItem.Editing.BeginEdit();
            contentItem.Versions.AddVersion();
            contentItem.Editing.EndEdit();
 
            return result;
        }
    }
}

In the case above, you can see that we are using the item that was selected by the user in the content browser and are executing the action on that item. There are a few variables you can access;

  • ItemID – This is the item ID of the Task item in the renderer library
  • LanguageIndex – This is the index value of the items in /sitecore/system/Languages – 0 would be the default ‘en’ language in this case
  • CurrentUserName – The name of the current logged in user
  • ci_projectPanel – The GUID of the last selected item on the Project panel.
  • ci_contentBrowser – The GUID of the last selected item on the Content panel.
  • ci_libraryBrowser – The GUID of the last selected item on the Library panel.
  • ci_imageViewer – The GUID of the last selected item on the Media panel.
  • ci_workBox – The GUID of the last selected item on the Workbox panel.

Step 2 – Reference the code to create the Task item

At the /sitecore/Print Studio/Libraries/Tasks library item, choose Insert > Task and correctly name your Assembly, TypeName and MethodName as per your code and project

Step 3 – Ensure that the tasks are enabled in the InDesign plugin

Result

Tasks are also documented for the end user on the Sitecore Developer Network here in an older version (https://sdn.sitecore.net/upload/sdn5/products/aps/11/indesign%20connector%20user%20manual.pdf ) . Although they are not deprecated, the functionality has been removed from the documentation. However, given the demand for this functionality, I thought it was worth resurrecting it.

2 – item:save event handler

Working with the item:save trigger has the advantage in that it can work seamlessly in the background of the save event, and can act upon multiple items. However working with the item:save event is tricky business, and a poorly coded trigger will affect performance for all Sitecore save operations. Also this method does not initiate feedback to the InDesign client.

Rather than replicating the code in its entirety, I will merely link to a blog posting from Dan Sinclair at Sitecore partner Horizontal Integrations.

http://blog.horizontalintegration.com/2015/12/11/add-support-for-content-workflow-with-sitecore-pxm/


  • TRENDnet's 1-Port Multi-Function USB Print Server, type TE100-MFP1, modifies very unique multi-function as well as conventional USB printers into a distributed community resource. Set up your multifunction printer in the numerous comfortable area as well as then link the efficient TE100-MFP1 to a connected system.