Automate app function runs
To run a function automatically based on predefined conditions, use the Workflows app. There are numerous reasons why you might want to run a function automatically, for example:
- To fetch data from external systems and write time series
- To sync an app state with an external system
Solution
In the Workflows app, create a workflow with the trigger of your choice and a task of type Run Javascript
to call the function:
export default async function () {
const response = await fetch('/apps/my.demo.app/api/query-external-data');
if (!response.ok) {
const responseText = await response.text();
throw new Error(`Request failed with status ${response.status}. Response text: ${responseText}`);
}
}
The URL follows the same pattern as for calls from the app UI. In this example, my.demo.app
is the ID of the app and query-external-data
is the name of the function.
Still have questions?
Find answers in the Dynatrace Community