# Creation of a trigger for prepayments based on the bookyear via formula

**URL:** <https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954>\
**Category:** Insights\
**Created:** [November 20, 2020, 8:38am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954 "2020-11-20T08:38:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wsteppe](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/wsteppe/32/1350_2.png) [@Wsteppe](https://community.silverfin.com/u/Wsteppe)\
**Post date:** [November 20, 2020, 8:38am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/1 "2020-11-20T08:38:42Z")

</div>

Hi,

We’re looking into some ways on how to use the Insights functionality.

One of the ideas is to have an automated (daily) trigger that notifies our team members that specific prepayment deadlines are coming. There’s already some predefined segmentation in the app that defines “companies in a payable position”, but this would not fit our usecase.

We were wondering if it would also be possible to define triggers based on more complex logic / dynamic segments that change in relation to the current date.

Eg:  
“Make a notification 2 weeks before a prepayment deadline comes up, which is end of bookyear - 2 months”.

“Make a todo 8 weeks before filing deadline, for all companies which do not yet have a trial balance uploaded.”

Any ideas on how to tackle these usecases?

---

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [November 20, 2020, 9:24am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/2 "2020-11-20T09:24:48Z")

</div>

Hi there,

You could create a template with variables that contain the current date, the deadline date and the difference between these two, for example:

```auto
{% assign current_date = "now" | date:"%d/%m/%Y" %}
{% input custom.deadline.prepayments as:date assign:deadline_date %}
{% assign date_difference = deadline_date-current_date | integer %}

```

In this case the date\_difference will return the difference in days so you can create a segment in your insights that searches for clients with a date\_difference \<= 14 (if the deadline is within 2 weeks)

First we store this difference in a result tag in our template (to be able to use it later on insights):

```auto
{% result 'date_difference' date_difference %}

```

Then we go to insights and create a segment with the following filter:

![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/1/1d64777cb26ab50f06649e897d0480a53d12ce00.png)

Once we save this segment, we will be able to create a trigger that notifies certain users on a daily basis for the specific clients that meet the above criteria:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/a/a641a9ff47bac62df9b516d313ebbfba586366a2.png)

I hope that helps.

Best,  
Borja

---

<div class="post-metadata">

**Author:** ![Wsteppe](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/wsteppe/32/1350_2.png) [@Wsteppe](https://community.silverfin.com/u/Wsteppe)\
**Post date:** [November 20, 2020, 9:27am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/3 "2020-11-20T09:27:44Z")

</div>

Sounds great, will the variable be updated in the background, or does it require user interaction before it’s updated?

(I thought templates would only recalculate if a user opens them, or they receive a ping from another updated template)

---

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [November 21, 2020, 7:00pm UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/4 "2020-11-21T19:00:23Z")

</div>

Hi,

The variable will be updated automatically if you include a workflow filter on your segment, like this:

![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/5/5cc49cfa1447572b19f86ddbdbfdaf262659e52a.png)

This makes the filter refresh all clients matching the criteria so it can take a while to load but should work fine.

Best,  
Borja

---

<div class="post-metadata">

**Author:** ![Wsteppe](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/wsteppe/32/1350_2.png) [@Wsteppe](https://community.silverfin.com/u/Wsteppe)\
**Post date:** [November 24, 2020, 10:23am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/5 "2020-11-24T10:23:20Z")

</div>

Thanks, this should do the trick then 🙂

---

<div class="post-metadata">

**Author:** ![dominic](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dominic](https://community.silverfin.com/u/dominic)\
**Post date:** [April 8, 2021, 5:49pm UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/6 "2021-04-08T17:49:57Z")

</div>

Hi Borja,

I was wokring on creating a similar to trigger to send out notification based on upcoming dates. Is there any restrictions on how many triggers could be run using the same segment? As it appears that when a trigger is run and the note is sent out re-running the same trigger is not sending out a note unless the original note is deleted.

Is this the expected function of a trigger? I guess this should work if there no changes to the date are made but looks like if there is a change to the deadline date would an updated trigger note wouldn’t be sent out unless the original note is removed.

Please let me know.

Thanks,

Dominic

---

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [April 9, 2021, 10:53am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/7 "2021-04-09T10:53:09Z")

</div>

Hi Dominic,

I don’t think there a specific limitation on the number of triggers you can use.  
The triggers can be run either **manually** (the note will be sent when the condition is met) or **daily** (the note will be sent out every day as long as the condition is still met).

Are you using the “run once” button? If so, the note should be sent once you press it if the condition is met and if the note has not already been run on that day (you can’t run the same trigger more than once on the same day).

For more information regarding triggers please take a look at the following link:

> **[How to set up triggers \[ADMIN\] - Silverfin Help ENG](https://en.help.silverfin.com/article/842-how-to-set-up-triggers)**
>
> A trigger can be thought of as a preset notification so that you can be kept informed when certain key events take place within your library of accounting files

Best,  
Borja

---

<div class="post-metadata">

**Author:** ![dominic](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dominic](https://community.silverfin.com/u/dominic)\
**Post date:** [April 12, 2021, 3:47am UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/8 "2021-04-12T03:47:07Z")

</div>

Thanks Borja for the info.

I did both first ran the trigger “daily” the first time it worked but was testing out again and the note didn’t go out. So tired running the same trigger manually but no new note was send out. So thought maybe need to remove the original note and tried again to run the trigger manually a new note got sent out.

For e.g. I ran it the below trigger once first manually and the note got posted.

![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/4/42c6417c471309af17e7a343bd7ceaabbea311e0.png)

I try to rerun the trigger manually no new not got posted. I try to change the body of the note as well. But once I remove the above note and ran the trigger manually again the new note got sent.

![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/6/6934148caa4472c06e488cd2a965343828619fd4.png)

Is how the trigger would work? where it won’t send out new notes for the same trigger multiple times?

Thanks,

Dominic

---

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [April 13, 2021, 4:29pm UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/9 "2021-04-13T16:29:30Z")

</div>

Hi @dominic,

The trigger will only re-send a note if we change the condition of the segment on that particular period (e.g. the workflow completion goes from 50% to 100%) or if the note that was sent is removed. The reason behind this is that we don’t want to keep sending notifications to the user on a daily basis unless there is a change in the initial filters.

You could create then different triggers for different dates which is I guess what you are trying to achieve.

Best,  
Borja

---

<div class="post-metadata">

**Author:** ![dominic](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dominic](https://community.silverfin.com/u/dominic)\
**Post date:** [April 13, 2021, 7:20pm UTC](https://community.silverfin.com/t/creation-of-a-trigger-for-prepayments-based-on-the-bookyear-via-formula/1954/10 "2021-04-13T19:20:55Z")

</div>

Perfect thanks for the confirmation. I play around with the segments to achieve what we trying to do. Thanks again for prompt response.

Dominic
