0
votes

I have added a custom field to a screen and want to have a Selector to choose values from the Description of a specific attribute called BASEITEM.

[PXDBString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Document Number", Visibility = PXUIVisibility.SelectorVisible)]
[PXSelector(typeof(Search<CSAttributeDetail.Description,
 Where<CSAttributeDetail.AttributeID.StartsWith("BASEITEM")>,
 OrderBy<Asc<CSAttributeDetail.Description>>>),
 DescriptionField = typeof(CSAttributeDetail.Description)]

However, when I try to publish this I get errors.

Building directory '/WebSiteValidationDomain/App_RuntimeCode/'.
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(27): error CS1003: Syntax error, '>' expected
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(27): error CS1525: Invalid expression term ','
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(27): error CS1026: ) expected
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(27): error CS1003: Syntax error, ']' expected
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(28): error CS1519: Invalid token '>' in class, struct, or interface member declaration
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(29): error CS1519: Invalid token '=' in class, struct, or interface member declaration
/AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(29): error CS1519: Invalid token ')' in class, struct, or interface member declaration
Compiler time, seconds: 0.8243028
Validation failed.

enter image description here

1
Your code doesn't compile, you are missing a parenthesis at the end. DescriptionField = typeof(CSAttributeDetail.Description))] - Simon ML
I added the parenthesis you recommended...still error - David Eichner
[PXDBString(60, IsUnicode = true)] [PXUIField(DisplayName = "Document Number", Visibility = PXUIVisibility.SelectorVisible)] [PXSelector(typeof(Search<CSAttributeDetail.Description), Where<CSAttributeDetail.AttributeID.StartsWith("BASEITEM")>, OrderBy<Asc<CSAttributeDetail.Description>>>), DescriptionField = typeof(CSAttributeDetail.Description))] - David Eichner
error CS1003: Syntax error, '>' expected error CS1525: Invalid expression term ',' error CS1026: ) expected /AcuDocCenterWebsite/App_RuntimeCode/PX_Objects_IN_InventoryItem_extensions.cs(27): error CS1003: Syntax error, ']' expected error CS1519: Invalid token '>' in class, struct, or interface member declaration error CS1519: Invalid token '=' in class, struct, or interface member declaration error CS1519: Invalid token ')' in class, struct, or interface member declaration - David Eichner

1 Answers

1
votes

There are a couple of strange things in your attributes, so let's try if fixing them will resolve your problem. Here is the complete snippet that should work :

    [PXDBString(50, IsUnicode = true)]
    [PXUIField(DisplayName = "Document Number", Visibility = PXUIVisibility.SelectorVisible)]
    [PXSelector(typeof(Search<CSAttributeDetail.description,
     Where<CSAttributeDetail.attributeID,  Like<string_BASEITEMPCT>>,
     OrderBy<Asc<CSAttributeDetail.description>>>),
     DescriptionField = typeof(CSAttributeDetail.description))]

Here is the constant class used in the PXSelector attribute

    public class string_BASEITEMPCT : Constant<string>
    {
        public string_BASEITEMPCT()
            : base("BASEITEM%")
        {
        }
    }
  1. You were missing a parenthesis at the end of the PXSelector attribute which prevented build and publish.

  2. You need to use the classes inheriting IBqlField instead of specific field i.e. use the lowercase class instead of the uppercase field when doing BQL.

  3. To compare a field value to a string, use the Like<> operator and a string constant. To create that constant, create a class and specify the string value as the argument of the base constructor. The % at the end of "BASEITEM%" has the same purpose as the SQL wildcard %