How to Schedule a process on specific interval configured by user in Forge app

Hello Community,
I am working on developing one Forge app which will get data from third party API and create issues in JIRA based on that data. This process of collecting data and creating issues in JIRA needs to be scheduled for specific interval configured by user.
For Example : After installing the app in JIRA cloud user will configure the account of third party application (from which data will be collected) and the Interval (e.g. 2 hour). Onclick of submit button app will initiate one process which will collect data from third party API and create JIRA issues based on that data, and from now on this will run every interval configured by user.
Is there any way I can do this?

I think of using scheduled trigger but value of interval in scheduled trigger can only be ‘hour’, ‘day’, or ‘week’ and also user will not be able to configure that as this will be configured in manifest.yml file. Also scheduled trigger will be trigger immediately after app installation, So is there any way user can configure when to start that trigger?

Hey,

If you want to add that level of customisation you could create an hourly scheduled trigger that checks some user preferences (maybe stored in the Forge storage) before it executes the rest of the function.

The 2-hour example could check the current time, continue executing on odd-numbered hours, and stop on even-numbered hours.

It could also check a user-chosen start time, and not run until after it reaches that time.

Hey @AdamMoore
Thanks for the reply

I want to confirm one more thing if you can answer it will be very helpful.
is there any fix time interval or any upper limit for scheduled trigger to run the function very first time after the app installation?

It depends on the interval you’ve set. If it’s an hourly schedule the installations will be distributed evenly across the hour.

So the upper limit is basically the interval you’ve chosen but it could run much sooner.