Question
· Aug 8, 2017

Update an Item Setting Value in studio ?

Hello everyone .

I am trying to update a setting of an operation directly via the code of a business operation.

Concretely, my customer want a counter for the number of calls to the operation and the possibility to redefine the point of this counter.


I was thinking of something like:

set counter = <getSettingValue(“Count”)>
…
set counter = counter +1
do <setSettingValue(“Count”)> = counter

In other words, after each call, the parameter will be incremented, but if the user want to redefine it between 2 calls, he can and it will be took into account.

My parameter is present in my production class , this is the value '2000' that i would like to increment : 

My question is : Is there any method to do this ?

I'm using Caché Studio 2014.1.4 on Windows .

Thank you.

Regards

Discussion (6)1
Log in or sign up to continue

Probably not a good idea to change the production configuration settings with every operation call, each change will trigger a production update request on the production view.

If the customer wants to see a counter since a defined point then it sounds like there might be a point in time that can be used. In which case you get a count using SQL...

select count(id)
from Ens.MessageHeader
where TargetConfigName='CosTutorial.testIncrementalParameter'
 and TimeCreated between '2017-08-07' and '2017-08-08'

The short (incorrect) answer that you are looking for is

set ..Count=..Count+1
$$$TRACE(..Count)

BUT, if you do this, you will notice that whilst Count does indeed increase with each message, it will not persist back to your settings.

Setting properties on an operation are just for convenience, they provide read access to the values held back in the production XDATA / the table Ens_Config.Item

If you want to dynamically update the setting values then you will need to look at the classes, Ens.Config.Production and Ens.Config.Item

But, as stated, it's best not to hijack static settings for a dynamic purpose. Updating the settings with every message will cause a production update event each time, and possibly other side effects.

If you want to track dynamic values at the operation level then have a look at pre-built services and operations that implement $$$EnsStaticAppData and $$$EnsRuntimeAppData, these macro helpers will save things like counts back to a persistent global.

Seems like a lot of hard work when you could just query the count and add a base value to it.