Skip to main content

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. 

 

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
rPXDefault(typeof(Search<ParentTable.custPORefNbr, Where<ParentTable.ServiceOrderNbr, Equal<Current<ServiceOrderNbr>>>>))]


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.


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.


It is “soRefNbr” not “sORefNbr”


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


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