Solved

Acumatica PXSelector, search 2 columns in selector or get other values from selector fields.

  • 27 February 2024
  • 2 replies
  • 58 views

Userlevel 1
Badge

Hi everyone,

 

I am having screen with Supplier (Right) Grid.

Having fields Vendor Ref, Ref Nbr.

When i will select Matched Vendor ref. selector the related record should populate in Ref Nbr.

But in my case, i am having same Vendor reference nbr with same datatype so there is no unique field.

Ref Nbr     Vendor Ref

A               000011158

B               000011158

C               000011158

When i am select  B  - 000011158 it will populate A - 000011158.

 

 

 

Selector Code:

 

    #region MatchRefNbrExcel // working here commented below n added my code WIP
    [PXDBString(255, IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "Matched Vendor Ref.")] // Rajani changed on 29 Jan 2024
                                                   
    [PXSelector(
typeof(Search5<APInvoice.invoiceNbr,
    InnerJoin<BAccountR,
        On<BAccountR.bAccountID, Equal<APInvoice.vendorID>>,
    InnerJoin<APRegister,
        On<APRegister.refNbr, Equal<APInvoice.refNbr>>,
    InnerJoin<APRegisterKvExt,
        On<APRegister.noteID, Equal<APRegisterKvExt.recordID>>>>>,
     Where2<
        Where<APInvoice.vendorID, Equal<APAutomatedReconciliation.vendorID.FromCurrent>,
            Or<BAccountR.parentBAccountID, Equal<APAutomatedReconciliation.vendorID.FromCurrent>>>,
        And<APInvoice.docType, Equal<Current<doctypeExcel>>,
        And<
           Where<APRegisterKvExt.valueString, Equal<AttrMatchType>,
               And<Where<APRegisterKvExt.valueString, NotEqual<AttrMatchTypeAuto>,
                  Or<APRegisterKvExt.valueString, NotEqual<AttrMatchTypeManual>>>>>>>>,
 Aggregate<
      GroupBy<APInvoice.refNbr,
    GroupBy<APInvoice.invoiceNbr,
    GroupBy<APInvoice.docType>>>>>),
typeof(APInvoice.docType),
typeof(APInvoice.docDate),
typeof(APInvoice.vendorID),
typeof(APInvoice.refNbr),
typeof(APInvoice.curyOrigDocAmt),
typeof(APInvoice.invoiceNbr),
ValidateValue = false,Filterable =true)]

    public virtual string MatchRefNbrExcel { get; set; }
    public abstract class matchRefNbrExcel : PX.Data.BQL.BqlString.Field<matchRefNbrExcel> { }
    #endregion

 

Logic :

 protected virtual void APAutomatedReconciliationLineExcel_MatchRefNbrExcel_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
 {
     APAutomatedReconciliation Header = this.Document.Current;
     APAutomatedReconciliationLineExcel line = e.Row as APAutomatedReconciliationLineExcel;
     string errormsg = string.Empty;

     if (Header.Status == "C")
     {

         APInvoice excel = PXSelect<APInvoice,
            Where<APInvoice.invoiceNbr, Equal<Required<APInvoice.invoiceNbr>>>>
            .Select(this, line.MatchRefNbrExcel); // Commented above and added this 9 Feb 2024 Rajani

         if (excel != null)
         {
             if (line.MatchRefNbrExcel == excel.InvoiceNbr && line.APStatementDocBalIncVatExcel == excel.CuryOrigDocAmt && line.DocTypeExcel == excel.DocType)
             {
           
                 line.MatchTypeExcel = "Unmatched";
               line.RefNbr = // Here i want Selected records Reference Nbr

                 APInvoiceEntry Graph = PXGraph.CreateInstance<APInvoiceEntry>();
                 Graph.Clear();
                 APInvoice AP = PXSelect<APInvoice,
                                     Where<APInvoice.refNbr, Equal<Required<APInvoice.refNbr>>,
                                     And<APInvoice.docType, Equal<Required<APInvoice.docType>>
                                     >>>.Select(this, excel.RefNbr, excel.DocType);
                 if (AP != null)
                 {

                     AP.PaySel = true;
                 }
                 else
                 {
                     AP.PaySel = false;
                 }
                 AP = Graph.CurrentDocument.Update(AP);
                 Graph.Actions.PressSave();

             }
             else
             {
                 errormsg = "Values Should Match."; // Rajani changed message 29 Jan 2024

                 line.Reconciled = false;
                 line.MatchTypeExcel = "Unmatched";
                 line.ReconciliationReasonExcel = "";
                 line.MatchRefNbrExcel = "";

                 PXUIFieldAttribute.SetError<APAutomatedReconciliationLine.matchDocNbr>(cache, line, errormsg);
             }
         }
     }
 }

 

 

 

icon

Best answer by darylbowman 27 February 2024, 16:29

View original

2 replies

Badge +11

I don’t really see this being an easy fix. When you pick something from a selector, you don’t get the selector row back, only the selected value. As you said, you are going from less specific information and trying to get more specific information from it. That’s obviously not going to work. I see the best option to be creating a selector for the Invoice RefNbr instead, from which you can get the specific invoice values and Vendor Ref.

Userlevel 1
Badge

Thanks @darylbowman.

Will do the same.

 

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