Skip to main content
Solved

PXRestrictor to select a customer belonging to a specific Customer Class


kevlynch
Jr Varsity II
Forum|alt.badge.img

Hi,

I’m working on my first customization adding a new table / DAC with a foreign key linking to Customers.

The need is to restrict the selection of the customer to only customers belonging to a specific class.

This is what I currently have in my DAC definition for this field:
 

        #region CustomerID
        [PXRestrictor(typeof(Where<Customer.customerClassID, Equal<Customer.customerClassID.Contains<"SPECIAL">>>), "Not a Special Customer")]
        [Customer]
        [PXDefault]
        public virtual int? CustomerID{ get; set; }
        public abstract class customerID :
            PX.Data.BQL.BqlInt.Field<customerID>
        { }
        #endregion

I’m getting a “CS1031: Type expected” error on “SPECIAL”. I can’t find an example of creating a PXRestrictor condition that isn’t based around a boolean, null check or comparison to a value from a matching field on this DAC. Is there a way I can create this sort of hard-coded filter?

Appreciate any guidance here.

Best answer by Vignesh Ponnusamy

Hi @kevlynch,

Try defining the BQL parameter like below and use the BQLString object in the BQL query,

public class custClass : PX.Data.BQL.BqlString.Constant<custClass>
{
    public custClass() : base("SPECIAL") { }
}

//Update BQL query like below

[PXRestrictor(typeof(Where<Customer.customerClassID, Equal<Customer.customerClassID.Contains<custClass>>>), "Not a Special Customer")]

Hope that helps.! Feel free to post back if you have any questions.

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

3 replies

Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

Hi @kevlynch,

Try defining the BQL parameter like below and use the BQLString object in the BQL query,

public class custClass : PX.Data.BQL.BqlString.Constant<custClass>
{
    public custClass() : base("SPECIAL") { }
}

//Update BQL query like below

[PXRestrictor(typeof(Where<Customer.customerClassID, Equal<Customer.customerClassID.Contains<custClass>>>), "Not a Special Customer")]

Hope that helps.! Feel free to post back if you have any questions.


Nilkanth Dipak
Jr Varsity III
Forum|alt.badge.img+7

Hi @kevlynch,

You cannot include scalar values directly in BQL queries. You need to use a constant class like @Vignesh Ponnusamy suggested above to use it in PXRestrictor attribute.


kevlynch
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 12 replies
  • August 16, 2024
Vignesh Ponnusamy wrote:

Hi @kevlynch,

Try defining the BQL parameter like below and use the BQLString object in the BQL query,

public class custClass : PX.Data.BQL.BqlString.Constant<custClass>
{
    public custClass() : base("SPECIAL") { }
}

//Update BQL query like below

[PXRestrictor(typeof(Where<Customer.customerClassID, Equal<Customer.customerClassID.Contains<custClass>>>), "Not a Special Customer")]

Hope that helps.! Feel free to post back if you have any questions.

Hi Vignesh,

It took me a little while to be able to get back to this to implement your suggestion. It worked great with a small tweak to the PXRestrictor line :

[PXRestrictor(typeof(Where<Customer.customerClassID, Equal<custClass>>), "Not a Special Customer")]

Looks like I need to dive deeper into BQL.

 

Thank you so much for your help!


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