The CreatorCon Call for Content is officially open! Get started here.

How to restrict records in Database view using before query business rule?

Ankita Kolhe
Tera Contributor

Hi Community,

In the below database view, I want to display certain records based on a condition.

AnkitaKolhe_0-1712898276901.png

Condition:- If in one location there are multiple Membership Status, then only Membership status starts with 'Member' can be displayed on list and other records not need to be displayed.

 

Example:- For location 'Taiwan' ,there are 3 records. So only two records where Membership status is 'Member- Full Scope' should be shown.

 

AnkitaKolhe_1-1712898522475.png

 

Can someone please help how this can be achieved from Before Query business rule?

 

Thanks,

Ankita

8 REPLIES 8

Community Alums
Not applicable

Hi @Ankita Kolhe ,

As per my understanding if location is "India", you need to show Result with B 

so can you please  try to "setLimit" like 

current.setLimit(1);
 

Please mark correct and helpful if it wokrs for you 

Thanks and Regards 
Sarthak

 

Pratiksha Kalam
Kilo Sage

Hello,

In condition tab of Business rule pls add both condition if you want to trigger BR on that condition .

Like : entity location is Taiwan and 

         membership status is Member - Full Scope.

 

But if you want to do query the table based on above condition you will have to write encoded Query as

 

	current.addEncodedQuery('entity_location!=Taiwan^ORmembership_status =='Member_Full_Scope');

 

pls check actual value of field n add it Query.

 

 

If my answer is helpful pls mark helpful and correct !

Thank You.

 

Br,

Pratiksha,k

        

Hi @Pratiksha Kalam ,

 

Thanks for your response. However my requirement is bit different here.

It's just not for particular condition that needs to be applied based on locations and Membership Structure.

Let's have below examples:-

 

Membership Status 'A' always takes precedence over 'B' & 'B' over 'C'.

 

Example-1

So suppose we have three records where Location is 'Australia'.

Record1- Membership Status - A

Record2- Membership Status -B

Record3- Membership Status -C

 

Result- A (only one record should display where Membership Status is A)

 

 

Example-2

So suppose we have two records where Location is 'India'.

Record1- Membership Status -B

Record2- Membership Status -C

 

Result- B (only one record should display where Membership Status is B)

 

Hope it's clear now.

 

 

Jayant_M
Kilo Sage

Hi @Ankita Kolhe ,

 

You can try creating before query business rule on table which got created on database view with your encoded query condition.

 

Please mark my response helpful if it resolves your issue!