Hi Experts,
There is a counter which is used as part of an expression when creating new seeds.
I am trying to get the seed counter value to no avail.
var seedKey = 'SDM'+CounterValue('nmsSeedMember');
logInfo(seedKey);
Solved! Go to Solution.
Views
Replies
Total Likes
Solution:
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@lineNum"/>
</select>
</queryDef>
);
var result = query.ExecuteQuery();
var data = NLWS.xtkCounter.load(2521030); //id of counter
var c = data.value;
for each(var i in result) {
c++
data.value = instance.vars.c = c;
sqlExec("UPDATE " + vars.tableName + " SET sInternalName = 'SDM"+instance.vars.c+"' WHERE iLineNum="+i.@lineNum);
data.save();
}
Views
Replies
Total Likes
Hi @david--garcia ,
I don't think the CounterValue function can be used inside JavaScript. You may use querydef to fetch the value
var query = xtk.queryDef.create(
<queryDef schema="xtk:counter" operation="select">
<select>
<node expr="@name"/>
<node expr="@value"/>
</select>
<where>
<condition expr="@name= 'nmsSeedMember'"/>
</where>
</queryDef>
);
var resultSet = query.ExecuteQuery();
for each (var row in resultSet.*) {
logInfo(row.@name + " = " + row.@value )
}
Or you can use SOAP API to get incremented value of counter using this function.
Views
Replies
Total Likes
I scripted the following which loads the current value and also sets it.
var data = NLWS.xtkCounter.load(2521030); //id of counter
var c = data.value;
//logInfo(c+ " " +typeof c);
data.value = ++c;
data.save()
Now I guess I need to integrate it into the expression or some kind of loop, any ideas?
Views
Replies
Total Likes
Hi @david--garcia ,
Once you have the value in JavaScript, save it to an instance variable and then you can use in expression using $(instance/vars/xxx) format.
Views
Replies
Total Likes
Solution:
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@lineNum"/>
</select>
</queryDef>
);
var result = query.ExecuteQuery();
var data = NLWS.xtkCounter.load(2521030); //id of counter
var c = data.value;
for each(var i in result) {
c++
data.value = instance.vars.c = c;
sqlExec("UPDATE " + vars.tableName + " SET sInternalName = 'SDM"+instance.vars.c+"' WHERE iLineNum="+i.@lineNum);
data.save();
}
Views
Replies
Total Likes