Skip to main content
Answer

Selector on new field causing error

  • November 21, 2024
  • 4 replies
  • 132 views

Hello all,

I am trying to add a Selector attribute on a new field in order to store a vendor in a case screen customization using the Customization Project Editor. After I publish the customization, I receive the error: “Cannot create ctl00_phG_tab_t2_CstPXSelector122 control. The PXSelector attribute is missing for the UsrInst_InstallVendor field. Make sure the names of the data views specified for controls in the ASpX file match the names of the data views defined in the corresponding graph.”

I have added the following attributes in the UsrInst_InstallVendor field:

[PXDBInt]
[PXSelector(typeof(Search<PX.Objects.CR.BAccountR.bAccountID, Where<PX.Objects.CR.BAccountR.type, Equal<PX.Objects.CR.BAccountType.vendorType>>>))]
[PXUIField(DisplayName="Install Vendor")]

Then, I create the control on the tab I have added in the Cases screen customization. After publishing, the screen shows the selector, but when clicked, I receive the error message above. 

Am I missing a step in my customization? Any help would be appreciated! I can also supply any further details as needed. Thank you!

Best answer by DipakNilkanth

Hi ​@spforster,

Try to replace your code as below for the custom field.

I have attached Customization package for your reference.

#region UsrInstInstallVendor
[PXDBString(255)]
[PXUIField(DisplayName="Install Vendor")]

[PXSelector(
typeof(Search<PX.Objects.CR.BAccountR.bAccountID,
Where<PX.Objects.CR.BAccountR.type, Equal<PX.Objects.CR.BAccountType.vendorType>>>),
typeof(PX.Objects.CR.BAccountR.acctCD),
typeof(PX.Objects.CR.BAccountR.acctName),
SubstituteKey = typeof(PX.Objects.CR.BAccountR.acctCD),
DescriptionField = typeof(PX.Objects.CR.BAccountR.acctName))]

public virtual string UsrInstInstallVendor { get; set; }
public abstract class usrInstInstallVendor : PX.Data.BQL.BqlString.Field<usrInstInstallVendor> { }
#endregion

Hope, it helps!

4 replies

Forum|alt.badge.img+7
  • Captain II
  • November 21, 2024

You should avoid having underscore characters in your field names as it interferes with how the SQL statements are generated. I’d suggest changing UsrInst_InstallVendor to be UsrInstInstallVendor.


DipakNilkanth
Pro III
Forum|alt.badge.img+13

Hi ​@spforster,

Try to replace your code foe your custom field as below
 

#region UsrInstInstallVendor
[PXDBString(255)]
[PXUIField(DisplayName="Install Vendor")]

[PXSelector(
typeof(Search<PX.Objects.CR.BAccountR.bAccountID,
Where<PX.Objects.CR.BAccountR.type, Equal<PX.Objects.CR.BAccountType.vendorType>>>),
typeof(PX.Objects.CR.BAccountR.acctCD), // Display the Account ID in the selector
typeof(PX.Objects.CR.BAccountR.acctName), // Display the Account Name in the selector
SubstituteKey = typeof(PX.Objects.CR.BAccountR.acctCD), // Allows the user to search by Account ID
DescriptionField = typeof(PX.Objects.CR.BAccountR.acctName))] // Shows the Account Name as description

public virtual string UsrInstInstallVendor { get; set; }
public abstract class usrInstInstallVendor : PX.Data.BQL.BqlString.Field<usrInstInstallVendor> { }
#endregion

Hope it helps!


DipakNilkanth
Pro III
Forum|alt.badge.img+13
  • Pro III
  • Answer
  • November 21, 2024

Hi ​@spforster,

Try to replace your code as below for the custom field.

I have attached Customization package for your reference.

#region UsrInstInstallVendor
[PXDBString(255)]
[PXUIField(DisplayName="Install Vendor")]

[PXSelector(
typeof(Search<PX.Objects.CR.BAccountR.bAccountID,
Where<PX.Objects.CR.BAccountR.type, Equal<PX.Objects.CR.BAccountType.vendorType>>>),
typeof(PX.Objects.CR.BAccountR.acctCD),
typeof(PX.Objects.CR.BAccountR.acctName),
SubstituteKey = typeof(PX.Objects.CR.BAccountR.acctCD),
DescriptionField = typeof(PX.Objects.CR.BAccountR.acctName))]

public virtual string UsrInstInstallVendor { get; set; }
public abstract class usrInstInstallVendor : PX.Data.BQL.BqlString.Field<usrInstInstallVendor> { }
#endregion

Hope, it helps!


  • Author
  • Freshman I
  • November 22, 2024

@Django thank you for that suggestion, I have changed field names to avoid any potential complications

@Dipak Nilkanth Your code worked, once I learned where to place it. Being new to customizations, I though using the attributes of the field, under Data Access in the Customization Project Manager was the appropriate place to put the PXSelector attribute. However, after importing your example project, I was able to look closer and see how to add the cache extension and code for the selector there.

Thank you both very much for your help!