How to work with selector

Hello everybody,

today I want to write few words how to work with selectors in Acumatica.

So, imagine, you have the following selector in Acumatica:

<px:PXSelector ID="NmbUsrBillPMTask" runat="server" DataField="UsrBillPMTask"/>

In order to make it work as selector, you need to do the following:

[PXSelector(typeof(Search<PMTask.taskID>))]

if you'll do it, you'll receive following selector:

And if you choose there some value, you'll be able to see id represented as number. In my case it was 727.

But what if you want to make it more readable?

Then you can add following part:

[PXSelector(typeof(Search<PMTask.taskID>), SubstituteKey = typeof(PMTask.taskCD))]

Then instead of some strange number Acumatica will display TaskCD field. 

But what if you have desire to add as display one more field displayed after "-" sign, as it is in some Acumatica screens. You can add another element, which is named DescriptionField. 

And final part of advice, you can also customize which fields should go in the selector. Take see at the following code:

[PXSelector(typeof(Search<PMTask.taskID,
            Where<PMTask.projectID, Equal<Current<PMTask.projectID>>>>), new Type[]{typeof (PMTask.taskCD), typeof (PMTask.locationID),
                typeof (PMTask.description), typeof (PMTask.status)}, SubstituteKey = typeof(PMTask.taskCD), DescriptionField = typeof(PMTask.description))]

You can try to figure out details at screenshot:

Hope that can help somebody to create selector.

2 Comments

  • dedi said

    Hello

    I made code like this

    [PXDBString(5)]
    [PXUIField(DisplayName="Case No")]
    [PXSelector(typeof(Search<ShipmentSKR.SOShipLineCaseNoSKR.CaseNbr>))]



    I created this code for custom field in shipment tab packages, ShipmentSKR.SOShipLineCaseNoSKR.CaseNbr Is a custom table, But when publish, there is an error likes this

    IIS APPPOOL\SKRDevTest
    Building directory '\WebSiteValidationDomain\App_RuntimeCode\'.
    \App_RuntimeCode\PX_Objects_SO_SOPackageDetail_extensions.cs(19): error CS0118: 'ShipmentSKR.SOShipLineCaseNoSKR.CaseNbr' is a 'property' but is used like a 'type'
    \App_RuntimeCode\PX_Objects_SO_SOPackageDetail_extensions.cs(19): error CS0118: 'ShipmentSKR.SOShipLineCaseNoSKR.CaseNbr' is a 'property' but is used like a 'type'
    Compiler time, in seconds: 7,510337

    Please Help Me, thank you

  • docotor said

    Hello Dedi. Your problem is not with code, but with MS SQL configuration. Your code is correct. You need to add user SKRDevTest as authorized at your SQL server

Add a Comment