0
votes

I am working on a process screen with an Action drop-down and a selector. I want the selector to display values based on Action selected. For example, I have an Action drop-down of two values 1. Prepare and Release Invoice and 2. Print COnsolidated Invoice and selector which shows Sales orders with Completed status when the first Action is selected. Can anyone give me an idea on how to implement this? Below is my filter table with Action and a selector fields.

      [Serializable()]
    public partial class ImportInvoiceFilter : PX.Data.IBqlTable
    {

   public const string PrintConsolidatedInvoice = "PCI";
   public const string PrepareAndReleaseInvoice = "PRI";
   public class prepareAndReleaseInvoice : Constant<string> { public prepareAndReleaseInvoice() : base(PrepareAndReleaseInvoice) { } }
   public class printConsolidatedInvoice : Constant<string> { public printConsolidatedInvoice() : base(PrintConsolidatedInvoice) { } }

    #region ReferenceID
    [PXString(30, IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "Customer Reference Nbr")]
    [PXSelector(typeof(Search<SOOrder.customerRefNbr,
                   Where<Where2<Where<SOOrder.status, 
     Equal<SOOrderStatus.open>,
                   And<Current<ImportInvoiceFilter.selectAction>, 
     Equal<ImportInvoiceFilter.prepareAndReleaseInvoice>>>,
                   Or<Where2<Where<SOOrder.status, 
     Equal<SOOrderStatus.completed>>,
                   And<Current<ImportInvoiceFilter.selectAction>, 
     Equal<ImportInvoiceFilter.printConsolidatedInvoice>>>>>>>),                         
     typeof(SOOrder.orderNbr),typeof(SOOrder.orderDesc), 
     typeof(SOOrder.customerRefNbr))]       
    public virtual string ReferenceID { get; set; }
    public abstract class referenceID : IBqlField { }

   #region SelectAction
        public abstract class selectAction : PX.Data.IBqlField
        {
        }
        protected string _SelectAction;
        [PXUIField(DisplayName = "Select ")]
        [PXStringList(new string[] { PrepareAndReleaseInvoice, PrintConsolidatedInvoice },
                       new string[] { "Prepare and Release Invoice", "Print Consolidated Invoice" })]
        [PXDefault(PrepareAndReleaseInvoice)]
        public virtual string SelectTemplate
        {
            get
            {
                return this._SelectAction;
            }
            set
            {
                this._SelectAction = value;
            }
        }
        #endregion

}

ASPX:

    <%@ Page Language="C#" 
    MasterPageFile="~/MasterPages/FormDetail.master" 
    AutoEventWireup="true" ValidateRequest="false" 
    CodeFile="KN506000.aspx.cs" Inherits="Page_KN506000" Title="Untitled 
    Page" %>
   <%@ MasterType VirtualPath="~/MasterPages/FormDetail.master" %>

   <asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
   <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%" 
   PrimaryView="Filter" TypeName="KNLANOrderProcess.OrderInvoiceProcess">
   </px:PXDataSource>
   </asp:Content>
   <asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
   <px:PXFormView ID="form" runat="server" DataSourceID="ds" Style="z- 
   index: 100" 
    Width="100%" DataMember="Filter">
    <Template>
    <px:PXLayoutRule runat="server" ID="CstPXLayoutRule8" StartColumn="True" ></px:PXLayoutRule>
  <px:PXDropDown runat="server" ID="CstPXDropDown10" DataField="SelectTemplate" CommitChanges="True" ></px:PXDropDown>
  <px:PXSelector runat="server" ID="CstPXSelector9" DataField="ReferenceID" CommitChanges="True" AutoRefresh="True" ></px:PXSelector></Template>
</px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server">
<px:PXGrid ID="grid" runat="server" DataSourceID="ds" Style="z-index: 100" 
    Width="100%" Height="150px" SkinID="Details" TabIndex="300" 
TemporaryFilterCaption="Filter Applied">
<EmptyMsg ComboAddMessage="No records found.
Try to change filter or modify parameters above to see records here." 
NamedComboMessage="No records found as &#39;{0}&#39;.
Try to change filter or modify parameters above to see records here." 
NamedComboAddMessage="No records found as &#39;{0}&#39;.
Try to change filter or modify parameters above to see records here." 
FilteredMessage="No records found.
Try to change filter to see records here." FilteredAddMessage="No records 
found.
Try to change filter to see records here." NamedFilteredMessage="No 
records found as &#39;{0}&#39;.
Try to change filter to see records here." NamedFilteredAddMessage="No 
records found as &#39;{0}&#39;.
Try to change filter to see records here." AnonFilteredMessage="No records 
found.
Try to change filter to see records here." AnonFilteredAddMessage="No 
records found.
Try to change filter to see records here."></EmptyMsg>
    <Levels>
        <px:PXGridLevel DataKeyNames="OrderType,OrderNbr,LineNbr" 
DataMember="ImportInvoiceList">
            <Columns>
                <px:PXGridColumn DataField="OrderType">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="OrderNbr">
                </px:PXGridColumn>
                <px:PXGridColumn DataField="OrderQty" TextAlign="Right" Width="100px">
                </px:PXGridColumn></Columns>
        </px:PXGridLevel>
    </Levels>
    <AutoSize Container="Window" Enabled="True" MinHeight="150" ></AutoSize>
</px:PXGrid>
</asp:Content>

Sample Screen: enter image description here

Graph:

public class OrderInvoiceProcess : PXGraph<OrderInvoiceProcess>
{
    #region Views
    public PXCancel<ImportInvoiceFilter> Cancel;
    public PXFilter<ImportInvoiceFilter> Filter;
    [PXFilterable]
    public PXFilteredProcessing<SOOrder, ImportInvoiceFilter> ImportInvoiceList;


    public PXSelect<SOOrder, Where<SOOrder.customerRefNbr, Equal<Current<ImportInvoiceFilter.referenceID>>
        >> SOOrders;

    #endregion
    public OrderInvoiceProcess()
    {
        ImportInvoiceList.SetProcessCaption("Process");
        ImportInvoiceList.SetProcessVisible(false);
        ImportInvoiceList.SetProcessAllCaption("Process ALL");
        ImportInvoiceFilter currentFilter = this.Filter.Current;

        ImportInvoiceList.SetProcessDelegate(
            delegate (List<SOOrder> list)
            {
                ProcessOrders(list, currentFilter, true);
            });
    }

    public IEnumerable importInvoiceList()
    {
        PXSelectBase<SOOrder> ImportOrderListBase = null;
        ImportInvoiceFilter currentInquiryfilter = Filter.Current;
        if (currentInquiryfilter != null && !string.IsNullOrEmpty(currentInquiryfilter.SelectTemplate))
        {
            switch (currentInquiryfilter.SelectTemplate)
            {
                case ImportInvoiceFilter.PrepareAndReleaseInvoice:

                    ImportOrderListBase = new PXSelectJoin<SOOrder, LeftJoin<SOOrderShipment, On<SOOrder.orderNbr,
        Equal<SOOrderShipment.orderNbr>>>, Where2<Where<SOOrderShipment.confirmed, Equal<True>,
            And<Where<SOOrderShipment.invoiceNbr, IsNull, And<SOOrder.customerRefNbr, Equal<Current<ImportInvoiceFilter.referenceID>>>>>>,
            And<Where<SOOrder.orderType, Equal<salesOrderTypeRO>,
                Or<SOOrder.orderType, Equal<salesOrderTypeCO>>>>>>(this);
                    return ImportOrderListBase.Select();

                case ImportInvoiceFilter.PrintConsolidatedInvoice:

                    break;
            }
        }
        return ImportOrderListBase.Select();

    }
}
1

1 Answers

2
votes

EDIT:

The other issue was that you were missing the base type attribute on the SelectAction field. You only had PXStringList:

[PXStringList(new string[] { PrepareAndReleaseInvoice, PrintConsolidatedInvoice },
                       new string[] { "Prepare and Release Invoice", "Print Consolidated Invoice" })]

PXStringList is not a base type so you should add the PXString attribute which is the base type:

[PXString(30, IsUnicode = true, InputMask = "")]
[PXStringList(new string[] { PrepareAndReleaseInvoice, PrintConsolidatedInvoice },
                   new string[] { "Prepare and Release Invoice", "Print Consolidated Invoice" })]

You can use your DAC filter field (selectAction) in the selector BQL query to filter the selector data based on your filter field:

    [PXSelector(typeof(Search<SOOrder.orderNbr,
                       Where<Where2<Where<SOOrder.status, Equal<SOOrderStatus.open>, And<Current<SOImportFilter.selectAction>, Equal<SOImportFilter.createandConfirmShipment>>>,
                       Or<Where2<Where<SOOrder.status, Equal<SOOrderStatus.completed>>, And<Current<SOImportFilter.selectAction>, Equal<SOImportFilter.printInvoice>>>>>>>

In the above BQL request the logic of the where clause is equivalent to:

If (sales order status is open And select action is create and confirm shipment)
Or (sales order status is completed And select action is print invoice)

You can tweak it with your own rules.

For this filter to work you need to handle refresh behavior with CommitChanges and AutoRefresh properties on the ASPX controls.

You need CommitChanges set to true to send back the filter DAC modifications to the business layer as soon as the user change it:

// In a Grid
<px:PXGridColumn DataField="SelectAction" CommitChanges="True" />

// In a Form or in the RowTemplate of the Grid
<px:PXDropDown runat="server" ID="edSelectAction" DataField="SelectAction" CommitChanges="True" />

For the Sales Order selector you need AutoRefresh set to true so that the BQL query of the selector is executed every time the user opens the selector instead of using the stale values from cache:

// In a Grid RowTemplate element
<px:PXGridLevel DataMember="YourDataView"
   <RowTemplate>
      <px:PXSelector runat="server" ID="edSalesOrderSelector" DataField="SalesOrderSelector" AutoRefresh="True" />
   </RowTemplate>                   

   <Columns>
      <px:PXGridColumn DataField="SalesOrderSelector" CommitChanges="True" />
   </Columns>
</px:PXGridLevel>

// In a Form
<px:PXSelector runat="server" ID="edSalesOrderSelector" DataField="SalesOrderSelector" AutoRefresh="True" />