Skip to main content
Solved

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

  • February 27, 2024
  • 2 replies
  • 176 views

rajanip50
Freshman I
Forum|alt.badge.img

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);
             }
         }
     }
 }

 

 

 

Best answer by darylbowman

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.

View original
Did this topic help you find an answer to your question?

2 replies

darylbowman
Captain II
Forum|alt.badge.img+13
  • 1712 replies
  • Answer
  • February 27, 2024

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.


rajanip50
Freshman I
Forum|alt.badge.img
  • Author
  • Freshman I
  • 10 replies
  • March 1, 2024

Thanks @darylbowman.

Will do the same.

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings