Solved

Show value of Service Order Custom Field on Appointment

  • 15 April 2022
  • 6 replies
  • 66 views

Userlevel 1

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. 

 

icon

Best answer by markusray17 15 April 2022, 20:30

View original

6 replies

Userlevel 7
Badge +3

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>>>>))]

Userlevel 6
Badge +3

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.

Userlevel 1

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.

Userlevel 6
Badge +3

It is “soRefNbr” not “sORefNbr”

Userlevel 1

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

Userlevel 1

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?

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 — 2022  Acumatica, Inc. All rights reserved