I'm working on a workflow and I would like to be able to read the 'Target Extension' (targetData object) of the workflow on a script that I want to include on the 'Script' tab of a Delivery in the workflow (see img below) Also I would need to have more details about the recipient list fed from the workflow into the delivery.
I can use with no problem the objects targetData and recipient on the body of the delivery itself, but not on this script tab.
As with a JS activity in a workflow, it is not possible to get directly the xpath (storage path) of a Query activity in the Delivery script tab. So you can't use directly targetData object, which is undefined.
Hence, you must do a queryDef inside your Delivery script tab, as below (of course, adapt it with your own need, "query" of temp:query beeing the internal name by default of a query activity; and I have added firstName column in the Additional data section of the Query):
var queryTemp = xtk.queryDef.create(
<queryDef schema="temp:query" operation="select">
var res = queryTemp.ExecuteQuery();
logInfo("[WKF345] get the values of temp:query after a Query task execution whose name is query");
logInfo("[WKF345] Count of values = " + res.length());
logWarning("[WKF345] Error in getting the values of temp:query after a Query task execution whose name is query");
logError("[WKF345] Error number: " + e); // or use logWarning if the treatment must go on despite this error
Depending of what you have to do, it is easier to use the <%= targetData.xxxx %> in the delivery body, or you can also do the global queryDef directly in the Delivery script tab (replacing the Query activity box), but to my mind it is
less easier to read and maintain, and duplicate from a workflow to another for other needs; but it is a personal choice of course.