Skip to main content
Solved

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


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,

Best answer by Naveen Boga

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

          }

}

 

 

 

View original
Did this topic help you find an answer to your question?

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • Answer
  • May 25, 2021

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

          }

}

 

 

 


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+6

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. 


  • Author
  • Freshman I
  • 2 replies
  • May 26, 2021

Hi @Naveen B ,

Thanks. It works!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings