Avatar

Correct answer by
Employee Advisor

Hi Alistair,

You can do so by using queryDef API on the temporary schema created for Enrichment activity. Please follow the steps outlined below from the test I carried out. You can make changes as per your workflow.

  1. In my setup there is a query activity, followed by enrichment which is followed by JS code activity that will populate the instance variable with relevant data from Enrichment.
  2. Referring to attached screenshot, inside the enrichment I've generated a modified first name of recipient by appending the string " is my first name" to the existing recipient first name. So, John will be modified to "John is my first name" and will be tagged as newFirstName field. 
  3. Please see that the alias has been modified inside Enrichment output columns and the new field is called @newFirstName.
  4. Also referring to schema of enrichment the temporary table can be referenced using schema temp:enrich.
  5. Inside JS code activity, perform a queryDef call on this temp schema and then read from the relevant column.

Adding the code here for reference.

var query = xtk.queryDef.create( <queryDef schema="temp:enrich" operation="select"> <select> <node expr="@newFirstName"/> </select> </queryDef>); var resultSet = query.ExecuteQuery(); for each (var row in resultSet) { logInfo("From temp schema : " + row.@newFirstName); instance.vars.AKTEST = row.@newFirstName; logInfo("From instance variable : " + instance.vars.AKTEST); }

When my sample workflow is executed, the output is 

Hope this helps.

Regards,

Vipul

View solution in original post