Solved

The function will be called several times when the form is loading

  • 25 May 2021
  • 3 replies
  • 143 views

Hi Experts,

I have a data view called ‘ReportCredential’ in my PXGraph. I set ‘ReportCredential’ as a primary view for a PXFormView. Also I have a funtion called ‘reportCredential’. When the form is loading, I find the function will be called several times. Since I will call external web services in this function, I need this function to be called only once. Is there any other event handlers for the screen loading? The following is my code.

 

Thanks,

icon

Best answer by Naveen Boga 25 May 2021, 12:18

View original

3 replies

Userlevel 7
Badge +17

Hi @DennyYang14,

You have written the view delegate i.e “reportCredential”, which will invoke multiple times when commits happened on the form document level.

Still, you can have a flag i.e. in side this viewdelegate like below, and which invoke only when you are making an API call.

 

public virtual IEnumerabel reportCredential()

{

         if(Base.IsContractBasedAPI == true)

          { 

              // logic here

          }

}

 

 

 

Userlevel 7
Badge +5

Hello Denny, 

I suggest you to cache the result somewhere and return the cached result instead of calling the external web service every time. 

Also, I’m not sure if having the call to external web service in a view delegate is a good design overall. 

I’d recommend you to implement a separate process to sync the data and to display the cached data on the screen. 

Hi @Naveen B ,

Thanks. It works!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved