Olà Guillermo,
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.
Good:
logInfo("[WKFxxx] delivery.internalName = " + delivery.internalName)
Wrong:
logInfo("[WKFxxx] delivery.targetData.id= " + delivery.targetData.id)
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">
<select>
<node expr="@firstName"/>
</select>
<where>
</where>
</queryDef>)
try
{
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());
}
catch(e)
{
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
}
for each(var elt in res)
logInfo("[WKF345] elt.firstName = " + elt.@firstName);
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.
Regards
Jean-Serge