2
votes

I have the need in one of my customization to show a popup directly after the user modifies the value of one of the controls (in this case, a custom field in the SOLine of the Sales Order Entry screen). This popup shows some additional values in a grid that the user must select before completing the row.

Using the standard process a SmartPanel was added to the screen.

If I call this from an action / PXLookupButton, the popup shows and the grid is populated correctly.

If I move this to either the "FieldUpdated" or "RowSelected" event, the smartpanel is displayed however the grid is always empty. Once more, if I then click on the button the grid stays empty till I cancel the modifications and re-enter using only the button.

I tried calling the action's press method in these events as well but the same result occurs.

Watching SQL profiler and the debugger events I can see that the BQL statement is being executed and returning the correct rows it's just not displaying in the smartpanel's grid.

Is it possible to handle this type of request? I'm assuming I need to either move this to a different method and/or pass some additional values but haven't found the right combination.

This holds true on Acumatica 5.3 / 6.1

Any input would be appreciated.

1

1 Answers

3
votes

RowUpdated handler allowed me to achieve requested behavior and show SmartPanel after field value change.

Example below relies on custom unbound Trigger Dialog field declared for the SOLine DAC. When a user checks or uncheckes Trigger Dialog flag, the system will show Item Quantity dialog to update Quantity for selected SOLine record:

public class SOLineExt : PXCacheExtension<SOLine>
{
    #region TriggerDialog
    public abstract class triggerDialog : PX.Data.IBqlField
    {
    }
    [PXBool]
    [PXUIField(DisplayName = "Trigger Dialog")]
    public virtual bool? TriggerDialog { get; set; }
    #endregion
}

enter image description here

Very basic SmartPanel declaration in Aspx:

<px:PXSmartPanel runat="server" ID="CstSmartPanel2" Key="SOLineParam" Caption="Item Quantity" AutoRepaint="True"
                 CaptionVisible="True" AcceptButtonID="CstButton6" AutoReload="true" >
    <px:PXFormView runat="server" ID="CstFormView3" DataMember="SOLineParam" SkinID="Transparent" >
        <Template>
            <px:PXLayoutRule runat="server" StartColumn="True" />
            <px:PXNumberEdit runat="server" ID="CstPXNumberEdit10" DataField="OrderQty" />
        </Template>
    </px:PXFormView>
        <px:PXLayoutRule runat="server" StartRow="True" />
        <px:PXPanel runat="server" ID="CstPanel5" SkinID="Buttons">
            <px:PXButton runat="server" ID="CstButton6" DialogResult="OK" CommandName="ChangeOk" CommandSourceID="ds" />
            <px:PXButton runat="server" ID="CstButton7" DialogResult="Cancel" Text="Cancel" />
    </px:PXPanel>
</px:PXSmartPanel>

Accomplished with the SOOrderEntry BLC extension subscribing to RowUpdated handler for the SOLine DAC to show Item Quantity dialog to a user:

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    [Serializable]
    public class SOLineParams : IBqlTable
    {
        #region OrderQty
        public abstract class orderQty : PX.Data.IBqlField
        {
        }

        [PXDBDecimal]
        [PXDefault(TypeCode.Decimal, "0.0")]
        [PXUIField(DisplayName = "Quantity")]
        public virtual decimal? OrderQty { get; set; }
        #endregion
    }

    public PXFilter<SOLineParams> SOLineParam;

    public PXAction<SOOrder> ChangeOk;
    [PXUIField(DisplayName = "OK")]
    [PXButton(CommitChanges = true)]
    protected void changeOk()
    {
        var lineParams = SOLineParam.Current;
        Base.Transactions.Cache.SetValue<SOLine.orderQty>(Base.Transactions.Current, lineParams.OrderQty);
        SOLineParam.Cache.Clear();
    }

    public void SOLine_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
    {
        if (!sender.ObjectsEqual<SOLineExt.triggerDialog>(e.Row, e.OldRow) && e.ExternalCall == true)
        {
            SOLineParam.AskExt();
        }
    }
}

Another part of the extension class is ChangeOk action invoked by SmartPanel to update Quantity for selected record in the Document Details grid. To hide ChangeOk action from screen toolbar, it's also necessary to add the following command into PXDataSource.CallbackCommands collection:

<px:PXDSCallbackCommand Name="ChangeOk" Visible="False" />