Solved

How to add field to Customer Details AR402000

  • 3 December 2022
  • 7 replies
  • 171 views

Userlevel 3
Badge

Hi everyone,

I have a field named Project/Contract on Invoices and Memos (AR301000)

and I want bring this field to Grid on Customer Details screen

 

Could you please help me?

 

Thanks,

Khoi

icon

Best answer by Naveen Boga 3 December 2022, 18:02

View original

7 replies

Userlevel 7
Badge +17

Hi @mrthanhkhoi  It requires customization. Please find the customization steps below and hope this helps!

  1. Extend the ARDocumentEnq Graph
  2. Extend the ARDocumentResult DAC and the new field i.e.Project
  3. Add a new field selecting an event, in the extended graph and write the logic to load the Project field from the Invoices and Memos screen.
Userlevel 3
Badge

Hi @Naveen Boga,

Thank you for your hint but I the field isn’t shown data. Could you please advise me?

I tried with a simple field (single line of text) as an example with following step:

  • Create a custom field:
    public class ARDocumentResultExt : PXCacheExtension<PX.Objects.AR.ARDocumentEnq.ARDocumentResult>
    {
    #region UsrCustomerOrderNbr
    [PXString(50, IsUnicode = true)]
    [PXUIField(DisplayName = "Customer Order Nbr")]

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

     

  • Implement event handling
    protected void ARDocumentResult_UsrCustomerOrderNbr_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
    {

    var row = (ARDocumentResult)e.Row;
    if (row == null)
    {
    return;
    }
    ARDocumentResultExt resext = row.GetExtension<ARDocumentResultExt>();
    ARInvoice invoiceObj = PXSelect<ARInvoice,
    Where<ARInvoice.docType, Equal<Required<ARInvoice.docType>>,
    And<ARInvoice.refNbr, Equal<Required<ARInvoice.refNbr>>>>>.Select(Base, row.DocType, row.RefNbr);
    if (invoiceObj == null) { return; }
    resext.UsrCustomerOrderNbr = invoiceObj.InvoiceNbr;
    }

 

This field is always empty

 

 

Userlevel 3
Badge

Hi @Naveen Boga,

I found that the event handling in extension library isn’t registered successfully.

I extended Graph in Visual Studio

Then upload the file .dll but somehow this handling isn’t applied

 

If I go with create event handler directly in Customization Project Editor, it works fine.

Do you have any idea why the event handling in .dll file didn’t work?

Userlevel 7
Badge +17

Hi @mrthanhkhoi  Please find the code here. I have verified it and it is working as expected.

 

public class ARDocumentResultExt : PXCacheExtension<ARDocumentResult>
{
#region UsrCustomerOrderNbr
[PXString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Customer Order Nbr")]
public virtual string UsrCustomerOrderNbr { get; set; }
public abstract class usrCustomerOrderNbr : PX.Data.BQL.BqlString.Field<usrCustomerOrderNbr> { }
#endregion
}

public class ARDocumentEnqExt : PXGraphExtension<ARDocumentEnq>
{
protected void ARDocumentResult_UsrCustomerOrderNbr_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
ARDocumentResult row = (ARDocumentResult)e.Row;
if (row != null)
{
ARDocumentResultExt resext = row.GetExtension<ARDocumentResultExt>();
ARInvoice invoiceObj = PXSelect<ARInvoice, Where<ARInvoice.docType, Equal<Required<ARInvoice.docType>>,
And<ARInvoice.refNbr, Equal<Required<ARInvoice.refNbr>>>>>.Select(Base, row.DocType, row.RefNbr);
if (invoiceObj != null)
{
e.ReturnValue = invoiceObj.InvoiceNbr;
}
}
}
}

 

 

 

Userlevel 3
Badge

@Naveen Boga 

Thank you very much,

I found that I didn’t set property as CommitChanges =true for the field so it doesn’t work in my code

 

 

Userlevel 7
Badge +17

Ok Great. Thanks for the update @mrthanhkhoi 

Userlevel 3
Badge

Hi @Naveen Boga,

I do the same way to bring the field Customer->BillContact->FullName to Customer Details Screen with following code:

protected void ARDocumentResult_UsrAccountName_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
var row = (ARDocumentResult)e.Row;
if (row == null)
{
return;
}
Customer customer = PXSelect<Customer,
Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, row.CustomerID);
if (customer == null) { return; }
Contact billContact = PXSelect<Contact,
Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, customer.DefBillContactID);
if (billContact == null) { return; }
e.ReturnValue = billContact.FullName;
}

When I select the Customer for the first run, the result is correct as following: 

Note: Account Name is display name of UsrAccountName

However, if I select another Customer, the value of Account Name didn’t update (the value is from previous Customer)

Then I refresh the page, I got the correct one:

 

Somehow the event FieldSelecting is not affected immediately when I change the Customer.

Could you please advise me?

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