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

AndersBGS
Tera Patron
Tera Patron

Hi @Ankita Kolhe ,

 

Yes, you can write something similar in there clause after existing clause: && membership_status ==  'Member - Full Scope'.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi @AndersBGS ,

 

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

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.

 

 

Community Alums
Not applicable

Hi @Ankita Kolhe ,

I tried your problem on my PDI and I hope below answer works for you ! 

 

I created a query BR on Incidnet table (You can create on any table you want) and add below code 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.addEncodedQuery('short_description!=Test^ORshort_description=NULL');

})(current, previous);

Here you can give like 


    current.addEncodedQuery('membership_statusSTARTSWITHMember');
 
Result Before :
SarthakKashya2_0-1712903770633.png

Result After : 

 

SarthakKashya2_1-1712903791700.png

 

This remove short desc starts with Test

 

Please mark correct and helpful if it wokrs for you 

Thanks and Regards 
Sarthak

Hi @Community Alums ,

 

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

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.