Question
Lucas Bourré · 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

1
0 485
Discussion (6)2
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'

Hello Sean, thank you for your reply.


All I need is to put a parameter in my operation , and to be able to increment it in the studio ( and also be able to change it in the management portal ) .

I know how to get the parameter value, with a simple  " set value = ..Count " , but i didn't find anything to change this setting value.

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.

Settings are not really meant to be used like that.

If you want to report usage volume the best option would be creting a DeepSee cube over Ens.MessageHeader class. For a limited subset of analytic operations SQL may be enough.

Hello Sean, thank you for your reply.


All I need is to put a parameter in my operation , and to be able to increment it in the studio ( and also be able to change it in the management portal ) .

I know how to get the parameter value, with a simple  " set value = ..Count " , but i didn't find anything to change this setting value.

Pls. don't forget to mark your question as "answered" on Developer Community,
please click the checkmark alongside the answer you (as author of the question) accept