Sitecore PXM 8.0: Add a custom task to PXM and InDesign

Background

Sitecore Print Experience Manager (PXM) is great; you can create dazzling printable documents that reuse your existing Sitecore content. You can enable your designers to add a personal touch to each document, or configure automation to allow document creation on the fly.

One of the primary components of PXM is its InDesign Connector plugin (IDC). It facilitates communication between Sitecore PXM and InDesign, allowing a designer to:

  • add Sitecore content to an existing InDesign document
  • create and update PXM Projects, which are a Sitecore representation of an InDesign document
  • manipulate master documents, which are essentially InDesign templates
  • save content changes directly into Sitecore items

One of its lesser-known features, however, is the ability to execute a custom Task in PXM.

PXM Tasks

A PXM Task is simply a method that can be executed on the Sitecore PXM server from InDesign. It accepts a Dictionary with some parameters and allows you to return a string that will be output in a dialog box in InDesign.

Task Dictionary Contents

The dictionary will contain the following parameters

  1. ItemID (GUID of the Task item in Sitecore)
  2. LanguageIndex (int)
  3. CurrentUserName (logged in user)
  4. ci_projectPanel (GUID of the item selected in the Project panel)
  5. ci_contentBrowser (GUID of the item selected in the Content panel)
  6. ci_libraryBrowser (GUID of the item selected in the Library panel)
  7. ci_imageViewer (I’m not sure what this does; let me know in the comments!)
  8. ci_workBox (GUID of the item selected in the Workbox panel)

How To Create and Execute a Custom PXM Task

Create the Task Class

  1. Create a public class (does not need to inherit any base class or implement an interface)
  2. Add a method that accepts a Dictionary<string, object> and returns a string
  3. Do something in your task
  4. Return whatever text you would like to display in a dialog box in InDesign when the task completes

A simple class example

public class CustomTask
{
  public string ExecuteTask(Dictionary<string, object> dictionary)
  {
    return string.Format("Hello World! You selected {0} in your Project panel.", dictionary["ci_projectPanel"]);
  }
}

Create the Task Item in Sitecore

Add the Task item below the /sitecore/Print Studio/Libraries/Tasks library folder and fill in the fields

2016-03-11_1631

  • Assembly should be the DLL that contains your class (including the file extension, e.g. TestPxm.dll)
  • TypeName should be the fully-qualified type name of your class (e.g. TestPxm.Tasks.CustomTask
  • MethodName should be the name of the method you created (e.g. ExecuteTask)

Add the Tasks Library to Your Extensions Browser Library Nodes

  1. Navigate to /sitecore/Print Studio/Modules/InDesign connector/Other Settings/Extensions browser/Libraries
  2. Add /sitecore/Print Studio/Libraries/Tasks library in one of the empty nodes

2016-03-11_1633

Execute the Task

  1. Open InDesign and log into Sitecore
  2. Open the Extensions panel and select your task
  3. Click the Load button (the icon with the document and a little arrow on it)

2016-03-11_1636

One thought on “Sitecore PXM 8.0: Add a custom task to PXM and InDesign

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: