Solved

FieldSelecting doesn't effect immediately

  • 9 December 2022
  • 5 replies
  • 175 views

Userlevel 3
Badge

Hello team,

I am implementing function that bring field Account Name from Bill-To-Info section in Customer (AR303000) to Customer Details screen (AR402000)

Details of field Account Name from Bill-To-Info section:

When I first time select customer, the result is correct:

Then I select another Customer, this field is still remaining the previous result

If I refresh the page, this field will display correct name.

Here is my code: I create a field UsrAccountName in ARDocumentResult and implement FieldSelecting as following

        #region UsrAccountName
[PXString(255, IsUnicode = true)]
[PXUIField(DisplayName = "Account Name", Visibility = PXUIVisibility.SelectorVisible)]

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

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

 

I do the same way and could bring field from ARinvoice but somehow it doesn’t work with the field BillTo->FullName of Customer.

Do you have any idea?

Any suggestion would be appreciated.

icon

Best answer by mrthanhkhoi 11 December 2022, 10:34

View original

5 replies

Userlevel 7
Badge +8

@mrthanhkhoi is CommitChange of your screen for this field is set to True?

Userlevel 3
Badge

Hi @aaghaei,

Yes, I have set commit change = true already

 

Userlevel 7
Badge +8

@mrthanhkhoi 

I tested the below code and works perfectly. If it doesn’t work you might have other customizations that prevent it from properly functioning.

 

//DAC Ext:
using PX.Data;
using static PX.Objects.AR.ARDocumentEnq;

namespace HCL
{
[PXNonInstantiatedExtension]
public sealed class HCLARDocumentResult : PXCacheExtension<ARDocumentResult>
{
public static bool IsActive() => true;

#region UsrAccountName
public abstract class usrAccountName : PX.Data.BQL.BqlString.Field<usrAccountName> { }
[PXString(255, IsUnicode = true)]
[PXUIField(DisplayName = "Account Name", Enabled = false, Visible = true)]
public string UsrAccountName { get; set; }
#endregion
}
}


//Graph Ext:
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
using static PX.Objects.AR.ARDocumentEnq;

namespace HCL
{
public class HCLARDocumentEnq : PXGraphExtension<ARDocumentEnq>
{
public static bool IsActive() => true;

protected void _(Events.FieldSelecting<ARDocumentResult, HCLARDocumentResult.usrAccountName> 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;
}
}
}

//ASPX:
<px:PXGridColumn DataField="UsrAccountName" Width="70" CommitChanges="True" />

 

Userlevel 3
Badge

Hi @aaghaei,

I split the field definition and graph extension to new files (with same code) as following

Then it works. I don’t know why but it is too weird

Userlevel 3
Badge

Hi @aaghaei,

I’m so sorry. Is there anyway to change the answer to your response?

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