-->

Populate Field in Grid with selection of another F

2019-08-23 07:23发布

问题:

This specifically pertains to the Service Management module of Acumatica. On the Service Orders screen (SD300100) and under the Labor Tab. We would like when a new row is created and a Model Number is selected then the Service ID would automatically be populated based on what model number that is selected.

I have coded this:

protected void FSSODetService_ServiceID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
    {

        var service = (FSSODetService)e.Row;
        if (service == null) return;
        var equipment = (FSEquipment)PXSelect<FSEquipment,
        Where<FSEquipment.SMEquipmentID, Equal<Required<FSSODetService.SMEquipmentID>>>>.Select(Base, service.ServiceID);
        if (equipment != null)
        {
            e.ReturnValue = equipment.EquipmentTypeID;
        }
    }

This is leaving me this error when published.

\App_RuntimeCode\ServiceOrderEntry.cs(54): error CS0118: 'FieldService.ServiceDispatch.FSEquipment.SMEquipmentID' is a 'property' but is used like a 'type'
\App_RuntimeCode\ServiceOrderEntry.cs(54): error CS0118: 'FieldService.ServiceDispatch.FSSODet.SMEquipmentID' is a 'property' but is used like a 'type'

I feel like it has something to do with the setup of the Database values as they are capital in the beginning instead of lowercase. If any one has some knowledge about this, I would greatly appreciate it.

回答1:

Field name that start with a capital letter reference the property value field. Field name that start with a lower letter reference the type of the field.

In BQL query, you don't provide the values of the field to the query. You provide the type of the field so you have to use lowercase first letter:

PXSelect<FSEquipment,
Where<FSEquipment.sMEquipmentID, Equal<Required<FSSODetService.sMEquipmentID>>>>

In BQL query parameters you use the property value instead of the type so you use capital letter:

.Select(Base, service.ServiceID)

EDIT: You found a bug in the naming convention for the FieldService product. Instead of making the first letter upper/lower case like that: 'sMEquipmentID' / 'SMEquipmentID'

public abstract class sMEquipmentID : PX.Data.IBqlField { }
public virtual int? SMEquipmentID { get; set; }

They picked the third letter: 'SMequipmentID' / 'SMEquipmentID'

public abstract class SMequipmentID : PX.Data.IBqlField { }
public virtual int? SMEquipmentID { get; set; }

So for this field only (and not all the other ones) you should use the lowercase third letter 'SMequipmentID' in the BQL query.

If you have no access to source code, you can still open the ServiceDispatch.DLL with visual studio or other utilities like ILSpy to search and inspect the type names. Since ServiceDispatch wasn't originally a part of the core Acumatica product it does have a few other naming convention differences: