Find out how to execute actions after a delivery has been sent with Post-Processing in the Campaign, the Routing and the Service Provider!

📬🌍⚙️

Intro

There are 3 ways of handling any process after a delivery execution:

  1. Inside the Campaign Workflow
  2. With a Post-Processing workflow via the Routing External Account
  3. With a Post-Processing workflow Template via the Service Provider

Inside the Campaign Workflow

Add a Javascript Code activity after a delivery, with the following code:

logInfo('vars.deliveryId:', vars.deliveryId); // will display "vars.deliveryId: 999999"
var delivery = NLWS.nmsDelivery.load(vars.deliveryId);
logInfo('delivery.label:', delivery.label); // "My Delivery Label"

You may debug by activating the feature “Display the tasks and the log”:

  1. Activate the option, it will bring up a new panel in the lower section of the Workflow, with 2 tabs: “Tasks” and “Journal”
  2. Select the activity that comes right after the delivery
  3. In the “Tasks” tab, make sure the first line is selected, and hit the “Detail” button
  4. Select the “Variables” tab
  5. You’ll find the XML version of the vars variable content, with the deliveryId attribute, hence vars.deliveryId

With a Post-Processing workflow via the Routing External Account

Instead of having code and process in a campaign (that should be kept simple), you may externalize your dev to a Post-Processing workflow.

To do so, follow the current steps:

  1. Create an new workflow with a Signal activity called signal, linked to JavaScript activity (use the same code as previous chapter), linked to an End activity.
  2. Duplicate your delivery’s current routing (Administration > Platform > External Accounts (nms:ExtAccount)) and then from the delivery Properties > General > Routing
  3. Change the Routing’s Delivery mode to External or Bulk Delivery, in order to reveal the Post-Processing... option
  4. Select the workflow you created in #1 as the Post-Processing workflow
  5. Leave the activity name to signal

Start the workflow, launch your campaign/delivery and debug the workflow, like before. you’ll have the following variables in the eventVariables XML doc:

  • vars.deliveryId: the delivery id
  • vars.description
  • vars.filename: the absolute or relative filepath of the generated delivery external file

NB: Using a standard delivery activity with “Send a Proof” works well with this solution.

You may also use standard activities such as a Query on nms:broadLogRcp where @delivery-id = $(vars/deliveryIs), linked to an Update data:

With a Post-Processing workflow Template via the Service Provider

If you’d like to save and keep each workflow execution separate, you have to use a Workflow Template referenced by the Delivery’s Service Provider. The workflow template is configured as follow:

  1. Create a new Workflow Template with a JavaScript activity and an End
  2. Duplicate your routing
  3. Remove the Post-Processing workflow (if any) from the routing
  4. Create a new Service Provider in Administration > Campaign Management > Service providers (nms:supplier)
  5. Create a new Service (nms:supplierModel) in the newly created Service Provider
  6. Link the workflow Template in Jobs > Post-Processing > Workflow template
  7. In the Delivery, link the Supplier via Properties > Advanced > Service Provider > Service

In the workflow template, the main difference is the variable name, you now have access to:

  • instance.vars.iDeliveryId: delivery id
  • instance.vars.iOperationId: campaign id
  • instance.vars.strFileName: the absolute or relative filepath of the generated delivery external file
  • No more Signal activity

Feel free to test with the below JavaScript code:

logInfo('instance.vars.iDeliveryId:', instance.vars.iDeliveryId);
logInfo('instance.vars.iOperationId:', instance.vars.iOperationId);
vars.filename = instance.vars.strFileName;
logInfo('vars.filename:', vars.filename);
instance.vars.isProof = NLWS.nmsDelivery.load(instance.vars.iDeliveryId).FCP;
logInfo('instance.vars.isProof:', instance.vars.isProof);

NB: Using a standard delivery activity with “Send a Proof” doesn’t work with this solution.

NB 2: the standard supplierMgt workflow must be up and running for the Service Post-Processing workflow to be executed (Source)