ACC nmsSeedMember counter | Community
Skip to main content
david--garcia
Level 10
July 9, 2021
Solved

ACC nmsSeedMember counter

  • July 9, 2021
  • 4 replies
  • 1278 views

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);

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by david--garcia

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(); }

 

4 replies

Krishnanunni
Level 4
July 9, 2021

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.

david--garcia
Level 10
July 9, 2021

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?

Krishnanunni
Level 4
July 12, 2021

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.

 

david--garcia
david--garciaAuthorAccepted solution
Level 10
July 14, 2021

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(); }