Skip to main content
Solved

Show value of Service Order Custom Field on Appointment

  • Apr 15, 2022 3:11 PM UTC
  • 6 replies
  • 266 views
  • Translate All

Forum|alt.badge.img

I have a custom field (CustPORefNbr) on my Service Orders screen that I wish to display on any Appointments spawned from the parent Service Order. I have created a custom field (UsrCustPORefNbr) on the Appointments screen that I wish to fill with the value from the parent Service Orders CustPORefNbr.

It’s a read-only field on the Appointments screen; I don’t need it to update the database. It’s fine with me if it pulls the value from the Service Orders screen (DAC) every time the Appointment is displayed.

What’s the best code for doing this?

 

Thanks in advance for any consideration. 

 

Best answer by markusray17

It is “soRefNbr” not “sORefNbr”

View original

6 replies

jinin
Pro I
Forum|alt.badge.img+12
  • Pro I
  • Apr 15, 2022 3:47 PM UTC

Hi @davidpoole21 
You can add the BQL on the  DAC field with PXdefault attribute. 

Example code:

[PXDefault(typeof(Search<InventoryItem.baseWeight, Where<InventoryItem.inventoryID, Equal<Current<inventoryID>>>>))]

something like this
[PXDefault(typeof(Search<ParentTable.custPORefNbr, Where<ParentTable.ServiceOrderNbr, Equal<Current<ServiceOrderNbr>>>>))]

Translate

Forum|alt.badge.img+5
  • Jr Varsity II
  • Apr 15, 2022 5:13 PM UTC

If you are using a virtual field(not persisted in the database) you may want to use PXUnboundDefault instead of PXDefault. The main difference is that UnboundDefault will assign the value when data is selected from the database vs when data is inserted into the cache. 

 

If you do use PXDefault you will want to make sure to set the PersistingCheck to PXPersistingCheck.Nothing.

Translate

Forum|alt.badge.img
  • Author
  • Freshman II
  • Apr 15, 2022 6:22 PM UTC

Thanks. I didn’t realize I could put a query in an Attribute tag like that.

But I still get an error. When I do my Ctrl-Alt-Click, it says the field is SORefNbr in the FSAppointment DAC. Any idea why it isn’t finding it?

Thanks.

Translate

Forum|alt.badge.img+5
  • Jr Varsity II
  • Answer
  • Apr 15, 2022 6:30 PM UTC

It is “soRefNbr” not “sORefNbr”

Translate

Forum|alt.badge.img
  • Author
  • Freshman II
  • Apr 15, 2022 6:46 PM UTC

Really? Is that all it was? Thanks so much!

Translate

Forum|alt.badge.img
  • Author
  • Freshman II
  • May 25, 2022 8:10 PM UTC

I tried using the suggested [PXDefault(typeof(Search<ParentTable.custPORefNbr, Where<ParentTable.ServiceOrderNbr, Equal<Current<ServiceOrderNbr>>>>))], but publishing the customization caused our server to reboot itself endlessly.

This is the actual code from the Data Access FS.FSAppointment UsrRempCustPORefNbr nonPersistedField:

[PXString(25)]
[PXUIField(DisplayName="Customer Order")]
[PXUnboundDefault(typeof(Search<FSServiceOrder.custPORefNbr, Where<FSServiceOrder.refNbr, Equal<Current<FSAppointment.soRefNbr>>>>))]

 

What am I doing wrong? Anybody got another suggestion?

Translate