Solved

Event when open a screen


Userlevel 4
Badge +1

Hi all,

I want to show up a message when shipment(SO302000) loaded. Which event should I use? All events fired by some actions. I can’t find any like document loaded event. 

icon

Best answer by markusray17 8 August 2022, 21:46

View original

13 replies

Userlevel 7
Badge +5

I believe that you’re looking for the RecordSelected event.

Userlevel 7
Badge +16

Hi @larryly  

You add a business event for a data change for the creation of the Shipment:

 

Userlevel 4
Badge +1

@ddunn I tried. Looks like system doesn’t support this event.

 

@kbeatty21 Let me check into business event.

Userlevel 7
Badge +5

@larryly - sorry RowSelected

You should review the training courses as the list of events are given with when you should use them.

Userlevel 4
Badge +1

@ddunn For my case. I can’t use row level event because that will fire the event every time when I want to click into a shipment and also the SO3020PL will throw an error. I’m looking for a high level event or document initialize event. 

Userlevel 6
Badge +5

 

Here’s the Acumatica Event order graphic. RowSelected will fire quite frequently. There isn’t a specific event for “Document Loaded” that will only fire once when the shipment is opened.

The closest you can get(as far as I am aware) is creating a virtual field on the record(SOShipment) as a flag and then checking that in the RowSelected Event, once you process your logic you would want to make sure to set the flag to processed so you don't run it again.

Userlevel 6
Badge +4

I’m not sure if that screen has pop-up messages, but my sysadmin configures pop-up messages on vendors.  If you are programming and want it to do something as you change records in the screen, that would be RowSelected event.  If you want something to happen when the screen loads initially, you that would be Initialize.

 

#region Initialize
public override void Initialize()
{
    SSINSetup sSINSetup = setupSSIN.Current;
    base.Initialize();
}
#endregion

Userlevel 6
Badge +5

Initialize runs when the graph is created. The system recreates the graph on most requests meaning it will run on any committed change you make to the document(mainly fields marked CommitChanges and Actions). So if you are trying to show a message that will result in the user seeing the message with every action or committed field change.

 

We needed to implement pop up notes for Sales Orders and I ended up going the route I mentioned above with some additional logic to reset the virtual field when the order number changed or the Previous/Next actions were invoked. 

Userlevel 4
Badge +1

@Brian Stevens I tried to override Initialize but system throw an error. How do you do that?

Userlevel 6
Badge +5

If you are using the PXOverrideAttribute that would probably cause an error. The override method is defined in the PXGraphExtension class so no attribute is needed to override it. You only need the code that was shown above:

public override void Initialize(){
base.Initialize();

//Your Code Here
}

You also want to make sure you are putting that code inside of a graph extension. If you are already doing that sharing the error or the code would help us pinpoint the issue. 

Userlevel 4
Badge +1

@markusray17 I tried to add a warning when screen loaded. But it looks like TermsID is not available at this moment. 

 

 

 

Userlevel 6
Badge +5

Initialize runs when the graph is created. Two issues with that code though. Base.soorder.Current probably isn’t set at that point so you likely are getting a null reference error. Additionally using the Ask method actually throws an error and then calls the method again with the user input. That would probably cause all sorts of issues if you do that during the Initialize method.

Userlevel 6
Badge +3

@larryly I am trying to do the same thing you are doing.  Almost exactly. I just want a popup to show one time when the page is opened, when a specific condition in a custom table is met.

I extended the Filter of the page with a couple boolean fields to check if the popup has been displayed so it only gets displayed one time.  However, the only place I can get it to work is in say, the FieldUpdating event or the FieldVerifying event of the Filter for the page.  Unfortunately, when a screen is first displayed, neither of those events get fired.  You have to actually change a field in the Filter to get it to fire.   

If I try to use the Initialize override, it just displays the actual message on the screen as an “exception”.  If I put it in a RowSelected event for the Filter, it throws an error because it causes a recursive error.

It seems like any event handler will cause a recursive call to the popup and throws an error.

What event did you find worked for you?

Thanks!

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