acumatica

hello world button in acumatica not working


here is my code. it adds a button to the customer screen, the button calls out but gets this in response,

0|<ctl00_phF_BAccount_t0_btnHelloWorld />

in AR303000 page aspx

<px:PXFormView ID="BAccount" runat="server" Width="100%" Caption="Customer Summary" DataMember="BAccount" NoteIndicator="True" FilesIndicator="True" ActivityIndicator="false" ActivityField="NoteActivity" LinkIndicator="true" BPEventsIndicator="true" DefaultControlID="edAcctCD">
<Template>
  <px:PXLayoutRule runat="server" StartColumn="True" ControlSize="XM" LabelsWidth="SM" ></px:PXLayoutRule>
    <px:PXButton runat="server" Text="Hello World" AutoCallBack="True" ID="btnHelloWorld">
 <AutoCallBack Command="HelloWorld" /></px:PXButton>
 <px:PXSegmentMask ID="edAcctCD" runat="server" DataField="AcctCD" FilterByAllFields="True" ></px:PXSegmentMask>
 <px:PXDropDown ID="edStatus" runat="server" DataField="Status" CommitChanges="True" ></px:PXDropDown>

in CODE in same customization project

using PX.Data;
using PX.Objects.AR; // for CustomerMaint graph
using PX.Objects.CR; // for BAccount DAC

public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
    // Define the action matching the button we will create
    public PXAction<BAccount> HelloWorld;

    [PXButton] // Indicates this is a button action
    [PXUIField(DisplayName = "Hello World")] // Label for the button/action
    protected void helloWorld()
    {
        // If this code runs, it will throw an exception and show a popup error in the UI.
        throw new PXException("Hello world from the server!");
    }
}

why don't I get an error message returned?? my return is this, 0|<ctl00_phF_BAccount_t0_btnHelloWorld />

It sends out a callback to the server but the return is not as expected as I do not think my code is being hit. Any suggestions. In the long run, I want to button to populate field values. But start here to just get the button functional.


Solution

  • You need to use Customer DAC in your action, as it is the main DAC in the CustomerMaint graph:

    public PXAction<Customer> HelloWorld;
    

    You don't need to modify the ASPX page at all, the framework will display the button using the code from your graph extension.