Sidebar

how do you use a global variable in a Mapping (i.e. to display records cnts after all records are added to a table(sql)

0 votes
441 views
asked Oct 17, 2014 by (170 points)
I want to create a global variable and then use it in a Mapping function, where i can add 1 for every successful database insert. then have a final additional mapping to display the counts using a qie.info message. appreciate your help.

1 Answer

0 votes

You can use the channel cache to store your count value untill you need it. Here is the code you can use.

To save out the value use:

channelCache.setValue('count', channelCache.getValue('count') + 1);

Note: you could also replace the number 1 with an iteration variable such as 'i' if you are in the context of a for loop to increment the current count of the channel cache variable.

Then when you are ready to use the value you can write it out with the following code.

qie.info(channelCache.getValue('count'));

answered Oct 20, 2014 by gary-t-8719 (14,860 points)
...