QueryDef returns empty results when conditions are met
Hi,
I have the workflow that insert a personalized string for each recipient, based on the provided value. Personalized strings and values are columns from the table xxx:userStrings. I wrote the function getRandomID(value) which looks for all records from userStrings table with provided value, adds their IDs to an array and then randomly returns one of IDs. After IDs is returned, the flag @used is set to be true.
function getRandomId(val) {
var q = xtk.queryDef.create(
<queryDef schema="xxx:userStrings" operation="select">
<select>
<node expr="@id"/>
</select>
<where>
<condition boolOperator="AND" expr={"@stringValue = '" + val + "'"}/>
<condition boolOperator="AND" expr={"@used = 0"}/>
</where>
</queryDef>
);
var results = q.ExecuteQuery();
logInfo("-------------Query results: " + results);
for each (var a in results) {
outputArr.push(a.@id);
}
randomId = outputArr[Math.floor(Math.random()*outputArr.length)];
return randomId;
}
For the smaller number of records (< 1000) it works fine but if it needs to run for larger batches, after some time it starts to return variables results (from above block of code) as empty. Clearly, it is not a true because I see and can query (using Query activity) records that fullfill above conditions.
Do you have any idea how to make it running?
Thanks,
Dominik