- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Hi @Greeshma_Sampath1 ,
If I understand the requirement correctly, then what you would like to have is a looped execution of query with different results at each execution. I think the following structure of workflow might satisfy that requirement.
I have created a file based on your data and loaded using the data loading.
Code inside definition:
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="customer_id"/>
<node expr="customer_type"/>
</select>
</queryDef>
)
var res = query.ExecuteQuery()
var keyValPair = {};
for each (var row in res) {
logInfo(row.customer_id);
logInfo(row.customer_type);
keyValPair[row.customer_id+row.customer_type] = [row.customer_id, row.customer_type];
}
keys=[];
vals=[];
len = 0;
for (var item in keyValPair) {
keys.push(item);
vals.push(keyValPair[item]);
len++;
}
//logInfo(keys)
instance.vars.combinations = vals;
//loop variable
instance.vars.loop = 0;
instance.vars.loopLength= len;You may skip data loading as you would have the original data in some schema. So replace the {var.targetSchema} with schema name like "nms:recipient". You might need to add '@' before column names when using schema.
Code inside loop definition:
instance.vars.cust_id = instance.vars.combinations[instance.vars.loop][0]; instance.vars.cust_type = instance.vars.combinations[instance.vars.loop][1];
In query activity, set the value expression as in below ss
Code in JavaScript code 3
instance.vars.loop++;
Test activity