Trigger examples

Explore scenarios to gain insights into how to customize the conditions for approval policies with practical situations, and adapt them to fit the distinctive needs and goals of your organization.

Overview

On this page, we delve into a variety of real-world scenarios of conditions for triggering approval policies. These scenarios are designed to help you understand how approval policies can be automatically set to specific invoices and how to customize these conditions to address specific operational, compliance, and governance needs within your organization.

  • The conditions mentioned on this page are designed using the MoniteScript and must be inserted into the trigger field. Check the Evaluated string section for further information about the syntax.
  • The "{event_name == 'submitted_for_approval'}" condition is mandatory in triggers.
  • The if, then, and else statements are not allowed in triggers.

By invoice amount

Set an approval policy for all invoices worth more than 300 EUR:

1{
2 "name": "Invoices worth more than 300 EUR",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 "{invoice.currency == 'EUR'}",
7 "{invoice.amount > 30000}"
8 ]
9 },
10 "script": [
11 ...
12 ]
13}

If you receive invoices in multiple currencies, you can convert the amount to some base currency to use the same threshold for all invoices:

1{
2 "name": "Invoices worth more than 300 EUR (after currency conversion)",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 {
7 "left_operand": {
8 "call": "Currency.convert",
9 "params": {
10 "amount": "{invoice.amount}",
11 "from_currency": "{invoice.currency}",
12 "to_currency": "EUR"
13 }
14 },
15 "operator": ">",
16 "right_operand": 30000
17 }
18 ]
19 },
20 "script": [
21 ...
22 ]
23}

With specific currencies

Set an approval policy for all invoices with specific currencies, in this case, EUR and USD:

1{
2 "name": "EUR and USD invoices",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 "{invoice.currency in ['EUR', 'USD']}"
7 ]
8 },
9 "script": [
10 ...
11 ]
12}

With specific tags

Set an approval policy for all invoices containing one of the specific tags:

1{
2 "name": "Invoices with specific tags",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 {
7 "any": [
8 "{'Marketing' in invoice.tags.name}",
9 "{'Urgent' in invoice.tags.name}",
10 "{'d566f374-463a-4a07-b252-2eb0200d62ce' in invoice.tags.id}",
11 "{'398b2748-b255-46da-b8dc-a01219539ec9' in invoice.tags.id}"
12 ]
13 }
14 ]
15 },
16 "script": [
17 ...
18 ]
19}

From a specific project

Set an approval policy for all invoices related to specific projects:

1{
2 "name": "Invoices from a specific project",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 "{invoice.project_id == 'd566f374-463a-4a07-b252-2eb0200d62ce'}"
7 ]
8 },
9 "script": [
10 ...
11 ]
12}

For specific counterparts

Set an approval policy for all invoices from a specific list of counterparts:

1{
2 "name": "Invoices from specific counterparts (vendors)",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 "{invoice.counterpart_id in ['398b2748-b255-46da-b8dc-a01219539ec8', '4d0ff737-070b-427a-980c-c8ee7961577d']}"
7 ]
8 },
9 "script": [
10 ...
11 ]
12}

For specific users

Set an approval policy for all invoices from a specific list of entity users:

1{
2 "name": "Invoices uploaded by specific entity users",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 "{invoice.was_created_by_user_id in ['d566f374-463a-4a07-b252-2eb0200d62ce', '398b2748-b255-46da-b8dc-a01219539ec9']}"
7 ]
8 },
9 "script": [
10 ...
11 ]
12}

By amount, currency, tags, AND specific counterpart

Set an approval policy for all invoices worth more than 1000 EUR, from a specific counterpart AND with specific tags:

1{
2 "name": "By amount, currency, tag, AND specific counterpart",
3 "description": "Invoices worth more than 1000 EUR, from a specific counterpart AND with specific tags",
4 "trigger": {
5 "all": [
6 "{event_name == 'submitted_for_approval'}",
7 "{invoice.amount > 100000}",
8 "{invoice.currency == 'EUR'}",
9 "{invoice.counterpart_id == '398b2748-b255-46da-b8dc-a01219539ec8'}",
10 "{'d566f374-463a-4a07-b252-2eb0200d62ce' in invoice.tags.id}",
11 "{'398b2748-b255-46da-b8dc-a01219539ec9' in invoice.tags.id}"
12 ]
13 },
14 "script": [
15 ...
16 ]
17}

By counterpart, plus amount OR specific tag

Set an approval policy for all invoices from a specific counterpart worth more than $300 OR with a specific tag:

1{
2 "name": "By counterpart, plus amount OR specific tag",
3 "trigger": {
4 "all": [
5 "{event_name == 'submitted_for_approval'}",
6 "{invoice.counterpart_id == '398b2748-b255-46da-b8dc-a01219539ec8'}",
7 {
8 "any": [
9 "{invoice.amount > 30000}",
10 "{'d566f374-463a-4a07-b252-2eb0200d62ce' in invoice.tags.id}"
11 ]
12 }
13 ]
14 },
15 "script": [
16 ...
17 ]
18}