Site icon Horizontal Blog

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:

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

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

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)

Exit mobile version