Hey guys,

I am building an application in which I consume a REST API. One of the requirements is to store the original request-url and corresponding response message, in combination with an requestID provided by the producer of the RESTAPI in the response body. The way I solve this is the following:

  1. In an OnBeforeRequest I store the request-url as session variable
  2. In an InAfterResponse I store the request-url (from the session variable) and the response message in an entity, subsequently the ID of the record is stored as a session variable
  3. In the Server Action that calls the consumed API the requestID added to the Entity record with same ID (as stored in the session variable)

The solution seems to work when I debug, but I wonder if it still works if more Server Actions a initiated at the same time. Can someone confirm that the Session Variable value won't be affected by another (instance) of the Server Action?

Thanks!

- Funs

Hi Funs,

The lifespan of the session variable is throughout the user login session and thus if you perform other server action within the same login session it wont impact the existing session variable.

If you are updating the same session variable in other action the value will be changed and you will get the most recent value in it.

Please let me know if i understand your question correctly or not ?


Regards,

-PJ-

Hi Pramod,

Thanks for your reply. Something important I forgot to mention is that it is a server action that will be initiated by a timer, so there will be no direct user interaction.

Also I don't update the same session variable knowingly, but I guess my question is if OutSystems will do that when more server actions are initiated at the same time, or are they sequentially?


Kind regards,

- Funs

Solution

Hi Funs,

Thanks for the clarification, two things here .

1.  Since timer run asynchronous on a separate session thus if you are using Session variable in your timer they will be limited to that timer session itself and wont impact any user session.

2. No matter how many server action you initiated OS won't change your session data until any of your action does not have the code to update the session variable.


Regards,

-PJ-

Solution

Thanks Pramod, I guess the solution will also work for timers and more server action instances