Skip to main content

Query templates

What are Query templates and how to use them

No one likes to do work that can be easily automated. That's why we made Query templates to save you a lot of time and effort - it is a place you can store your jurisdictions risk ratings, industries or any other data you'd wish to use when you write your Scenarios, Risk Rules or Clearance rules.

💡An example.

Your list of high-risk countries as listed in the screenshot below are Afghanistan, Iraq, Myanmar, North Korea, Sudan, Syria, Uganda, and Yemen.
​

But, in 6 months, the world situation has changed and North Korea is no longer considered high-risk, but Hong Kong has suddenly been added to that list.
​

Rather than going through each and every one of your scenarios and risk rules — deleting North Korea and adding Hong Kong — you could just use query templates — and use the name in place of writing out every one of those countries.


Query template in use example

Below is an example scenario that generates an alert when young customer has a high value transaction with sender or receiver from a high risk country (and the query template name is iso2_high_risk_country).


Query Template Guidelines

Query templates with values separated by commas are case sensitive and should be used when an exact match is needed, e.g. high risk country lists. For example,

select new.attributes->>'sender_country' in ($high_risk_countries) 
from transaction new
where new.id = $transactionId

where the query template high_risk_countries contains IR, SY, NK, ...The sender country needs to match exactly an entry in the query template.
​

The ones separated by | are for pattern matching and are used most often for detecting red flag words in the transaction reference field. They are not case sensitive and allows regular expressions to be used. For example,

select new.reference ~* ($red_flag_words) 
from transaction new
where new.id = $transactionId

where the query template red_flag_words is drug|gun|bomb|...The reference can be longer than the entry in the query template, e.g. "Money for making bombs", but it would still match because "bomb" is present in the reference text.


How to edit or delete a query template

You can find query templates in Configuration page under all tabs, or use the quick access Query Templates item in the menu.

If you have the permissions to edit queries, then you should see an Edit button on the far right of each query.

From there, a pop-up box opens. There, you add or delete whichever part of that category has changed (i.e. remove 'KP' and add 'HK') and click Save. Or, if you want to delete it, pick the Delete button.

From then on, everything will be updated in all scenarios or risk rules that use that query template name you just edited.

❗ You won’t be able to change Query template’s name or delete a Query template if it is used in a Scenario, Risk rule or Clearance rule.


Editing values as a list

Instead of typing out one long comma-separated string, you can turn on Edit as list when editing a query template to add and remove values one at a time.

This only works for query templates with comma-separated values (e.g. country codes) — it's meant for exact-match lists, not the |-separated pattern-matching templates.

When you open a query template for editing, flip the Edit as list toggle and the content field turns into a list of tags, one per value. From there you can:

  • Type a new value and hit Enter to add it

  • Remove a single value by deleting its tag — no need to hunt for a comma in a long string

Salv wraps each value in quotes and joins them with commas behind the scenes, so the query template works exactly the same as before — this is just a friendlier way to edit it. You can toggle back to the raw text view at any time.


Reviewing changes before they go live (4-eyes principle)

If your organisation has the 4-eyes principle switched on for query templates, editing, creating, or deleting a query template works a little differently: your change won't take effect until someone else on your team reviews and approves it.

Say you edit iso2_high_risk_country to swap remove a country from it and hit Save. Instead of updating the template everywhere straight away, the system keeps the version that is currently Active untouched, and saves your edit as a pending change alongside it.

From here, someone else needs to open it via query templates list or "Review Requests" in the navigation bar, and either:

  • Approve it — your change takes over immediately, everywhere that template is used.

  • Reject it — your edit is discarded and nothing changes.

  • Withdraw it — same as reject, but this one's for the submitter: if you change your mind before anyone's reviewed it, you can pull it back yourself.

This is opt-in feature. Want it switched on for your organisation? Get in touch with your Salv contact.

Did this answer your question?