Solved

customization

  • 7 October 2023
  • 3 replies
  • 49 views

Userlevel 1

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? 

icon

Best answer by vardan22 7 October 2023, 07:42

View original

3 replies

Userlevel 4
Badge +1

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:

 

Userlevel 7
Badge +10

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

Userlevel 1

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved