Skip to main content
Answer

Create custom field with retrieve value from another table

  • October 30, 2025
  • 3 replies
  • 57 views

 

I have created a new custom field in SOOrder, I want to retrieve SalesPerson.descr from SalesPerson table but not showing value. I want SalesPerson Description insert it into the SOOrder table.

[PXDefault(typeof(Search<SalesPerson.descr, 
Where<SalesPerson.salesPersonID, Equal<Current<SOOrder.salesPersonID>>>>),
PersistingCheck = PXPersistingCheck.Nothing)]
[PXDBString(60)]
[PXUIField(DisplayName="SalesPerson Description")]

 

Best answer by darylbowman

@aleksandrsechin‘s analysis is correct.  However, there is an even simpler resolution.

Simply add the following attribute to the list of attributes you already have:

[PXFormula(typeof(Default<SOOrder.salesPersonID>))]

This will cause the FieldDefaulting event to run for your custom field whenever SalesPersonID is updated.

3 replies

Forum|alt.badge.img+3

The field is empty because PXDefault runs on insert, and when the SOOrder is created, SalesPersonID is null. After you update that field, PXDefault doesn’t trigger again.

I think you should remove the PXDefault attribute and instead create a Graph Extension with a FieldUpdated event handler like this:

 

 


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • October 30, 2025

@aleksandrsechin‘s analysis is correct.  However, there is an even simpler resolution.

Simply add the following attribute to the list of attributes you already have:

[PXFormula(typeof(Default<SOOrder.salesPersonID>))]

This will cause the FieldDefaulting event to run for your custom field whenever SalesPersonID is updated.


  • Author
  • Freshman I
  • October 31, 2025

Hi ​@darylbowman thanks a lot, it’s work