Search code examples
acumaticaacumatica-kb

How can I select a unique record in a selector if the CD is the same for both records?


I have a selector which selects from a table that has some records with the same CD field used as the selected value, but the ID is different. for example, I have two records with the following data in the table:

enter image description here

When the selector pops up, it shows the following:

enter image description here

And here's the selector code:

    public abstract class clientEINID : PX.Data.BQL.BqlInt.Field<clientEINID>{ }
    [PXDBInt()]
    [PXDefault()]
    [PXUIField(DisplayName = "Client FEIN")]
    [PXSelector(typeof(Search<xTACEntityMappingEIN.iD, Where<xTACEntityMappingEIN.taxDeptUse, Equal<True>, And<xTACEntityMappingEIN.active, Equal<True>>>>)
                , typeof(xTACEntityMappingEIN.eIN)
                , typeof(xTACEntityMappingEIN.commonName)
                , typeof(xTACEntityMappingEIN.entityType)
                , SubstituteKey = typeof(xTACEntityMappingEIN.eIN))]
    public virtual int? ClientEINID { get; set; }

The problem is, no matter which record I select from the selector, the ID that is returned is 565, or the first entry in the returned results. It's as if, since both CDs (the EIN field) are the same, it's not associating the actual ID value of the record I want with what is returned. How can I get the selector to return the correct ID for the second selection in the selector (the one with 566 as an ID)?


Solution

  • There seems to be no way to select the correct record if the CD is the same between two records with different IDs.

    I ended up concatenating a tie-breaking field value (the Entity type) on to the CD's value to make sure the CD was unique.