Skip to main content
Answer

customization

  • October 7, 2023
  • 3 replies
  • 127 views

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 VardanV

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:

 

3 replies

VardanV
Jr Varsity III
Forum|alt.badge.img+1
  • Jr Varsity III
  • 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
  • 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

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