Skip to main content
Solved

customization


Forum|alt.badge.img

select ValueID from CSAttributeDetail where AttributeID = 'MFGPRPALLE';

I need to get same result like above sql query. How can I get the result using PXSelector? 

Best answer by vardan22

To be able to use the constant string value in the PXSelector attribute you need to create the constant Bql class:

public class AttributeConstants
{
    public const string AttributeConstID = "MFGPRPALLE";

    public class attributeConstID : BqlType<IBqlString,string>.Constant<attributeConstID>
    {
        public attributeConstID() : base(AttributeConstID) { }
    }
}

After that, you can declare the field and put the PXSelector like the following:

public sealed class SOOrderExt : PXCacheExtension<SOOrder>
{
    public static bool IsActive() => true;

    #region UsrFakeField
    [PXDBString(10)]
    [PXUIField(DisplayName = "MFGPRPALLE")]
    [PXSelector(typeof(Search<CSAttributeDetail.valueID,Where<CSAttributeDetail.attributeID,Equal<AttributeConstants.attributeConstID>>>),new Type[]
        {
            typeof(CSAttributeDetail.valueID),
            typeof(CSAttributeDetail.description)
        })]
    public string UsrFakeField { get; set; }
    public abstract class usrFakeField : BqlType<IBqlString, string>.Field<usrFakeField> { }
    #endregion
}

Result:

 

View original
Did this topic help you find an answer to your question?

3 replies

vardan22
Jr Varsity III
Forum|alt.badge.img+1
  • Jr Varsity III
  • 44 replies
  • Answer
  • October 7, 2023

To be able to use the constant string value in the PXSelector attribute you need to create the constant Bql class:

public class AttributeConstants
{
    public const string AttributeConstID = "MFGPRPALLE";

    public class attributeConstID : BqlType<IBqlString,string>.Constant<attributeConstID>
    {
        public attributeConstID() : base(AttributeConstID) { }
    }
}

After that, you can declare the field and put the PXSelector like the following:

public sealed class SOOrderExt : PXCacheExtension<SOOrder>
{
    public static bool IsActive() => true;

    #region UsrFakeField
    [PXDBString(10)]
    [PXUIField(DisplayName = "MFGPRPALLE")]
    [PXSelector(typeof(Search<CSAttributeDetail.valueID,Where<CSAttributeDetail.attributeID,Equal<AttributeConstants.attributeConstID>>>),new Type[]
        {
            typeof(CSAttributeDetail.valueID),
            typeof(CSAttributeDetail.description)
        })]
    public string UsrFakeField { get; set; }
    public abstract class usrFakeField : BqlType<IBqlString, string>.Field<usrFakeField> { }
    #endregion
}

Result:

 


Forum|alt.badge.img+9
  • Semi-Pro III
  • 229 replies
  • October 7, 2023

Hi @tharinduweerasooriya90 ,

You need to use below code snippet for selector 

        [PXSelector(typeof(Search<CSAttributeDetail.valueID,
                  Where<CSAttributeDetail.attributeID, Equal<Required<defaultAttributeValue>>>>))]

and create a constant of default attribute as below.

   public const string DefaultAttributeValue = "MFGPRPALLE";
    public class defaultAttributeValue : PX.Data.BQL.BqlString.Constant<defaultAttributeValue>
    {
        public defaultAttributeValue()
            : base(DefaultAttributeValue)
        {
        }
    }

Hope, it helps!

Regards,

Sweta


Forum|alt.badge.img
sweta68 wrote:

Hi @tharinduweerasooriya90 ,

You need to use below code snippet for selector 

        [PXSelector(typeof(Search<CSAttributeDetail.valueID,
                  Where<CSAttributeDetail.attributeID, Equal<Required<defaultAttributeValue>>>>))]

and create a constant of default attribute as below.

   public const string DefaultAttributeValue = "MFGPRPALLE";
    public class defaultAttributeValue : PX.Data.BQL.BqlString.Constant<defaultAttributeValue>
    {
        public defaultAttributeValue()
            : base(DefaultAttributeValue)
        {
        }
    }

Hope, it helps!

Regards,

Sweta

This code also worked.

Thank you


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings