Global variable - assign value from a flow service

Is it possible to change the value of a previously defined global variable from a flow service? I have tried a number of different ways to change the value of the global variable, but not sure if global variables are meant to be changed from a flow service (as opposed to being changed from the IS admin screen).

Thanks

Yes … you may use WmRoot service(s) … check the dsp code where you can add/update GV. it will have an %invoke tag… use that servcie

I would check the java API to Add/update the global variables.

com.wm.util.GlobalVariables.getInstance().put()

Please check if these services help you for your need.

wm.server.globalvariables:addGlobalVariable
wm.server.globalvariables:editGlobalVariable
wm.server.globalvariables:removeGlobalVariable
wm.server.globalvariables:listGlobalVariables
wm.server.globalvariables:getGlobalVariableValue

Hope this helps.

-Kishore

I’m a bit curious as to what the use case is. Could you please elaborate?

In my experience with Global Variables, they are typically used for configuration items, and that being the case, you wouldn’t to change from the application itself.

If there’s a need to have a variable that can be used/modified across different services, then perhaps using the caching services would be a better option, or even creating your on Java static variables with getter/setter services.

Percio

1 Like

Percio ,
Is getter/setter are the static variables/properties of the class? Can we use it within the java service directly, how?

I agree with you that Constants should be used to set the config properties. Instead I also would prefer using the Caching services.

I have a similar problem as well. The global variable is a secret value.
It’s an OAuth access token that expires after 60 minutes and the OAuth refresh token that can be used to issue a new one.
Both these need to be stored as Global variables(and preferable as a secured secrets). The OAuth access token will be updated fairly frequently.

As an alternative has anyone had experinance fetching values from the AWS key store for use in webMethods. With AWS we could manage the OAuth token refresh and updating and just have webMethods fetch a value when it needs it. It would be nice if this value could be cached for say 30 minutes yet globally available in webMethods.

Hi Alan,

might it be possible to cache the services which are generating and returning these tokens via service properties and set the cache expiration time out accordingly?

In this scenario the tokens will only be cached while they are valid and removed from the cache when they have expired.

Regards,
Holger

1 Like

Alan,
It may not be a good idea to store an access token in Global variable as it expires. With an expiry time, most of the identity servers will issue the same token back when other clients (Integration servers) requests for the token with same client id, secret, scope - you could cache it in individual IS server in its local cache.

-Senthil

2 Likes

One alternative way is to call the get token service always , do not use refresh token , then no need to save(or cache) the refresh token .

Otherwise if you want to save the token , you can service cache with timeout set as expire value of the token .

1 Like