Skip to main content
Answer

ViewBag in Acumatica

  • July 13, 2021
  • 5 replies
  • 80 views

SadokHanini
Freshman II

Hello,

 

Can we use the viewBag in Acumatica?

or pass a value for example from Graph CAEntry to CAReleaseProcess 

 

Thanks.

Best answer by Gabriel Michaud

@Naveen B I personally think using session state is almost always the wrong solution -- take a look at the business logic in PX.Objects.dll; this is never used except for very very specific cases.

5 replies

Gabriel Michaud
Captain II
Forum|alt.badge.img+11

Hi Sadok,

Can you tell us more about the requirement and process? There are different ways to pass state between graphs, but using a ViewBag is not possible.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 13, 2021

Hi @SadokHanini We have used sessions long back, please find the code below.. that may help you.

 

Store the value in session:

PXContext.Session.SetString( TOKENConstant , tokenIDvalue);

Read the value from Session:

string tokenID = PXContext.Session[TOKENConstant].ToString();

 


Gabriel Michaud
Captain II
Forum|alt.badge.img+11

@Naveen B I personally think using session state is almost always the wrong solution -- take a look at the business logic in PX.Objects.dll; this is never used except for very very specific cases.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • July 13, 2021

Yes @Gabriel Michaud  We have used this session concept long back for specific reason in payment gateways, and currently we are NOT using it.

Since Sadok is looking for the Sessions, I just shared here.


Gabriel Michaud
Captain II
Forum|alt.badge.img+11

I have no doubt you know what you are doing @Naveen B, and payment processing is one of the scenarios where I see it used in PX.Objects 😉

The reason I mentioned it is because there are new users on this forum and they often try to replicate the same patterns they used in other systems without first getting a good understanding of how to do things the “Acumatica way”. This always comes back to bite you later and you discover issues that require major redesigning