Skip to main content

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.

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


Hi @aaghaei,

Yes, I have set commit change = true already

 


@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" />

 


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


Hi @aaghaei,

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


Reply