Create a Workflow to utilise in your App
Hello World - Workflow Creation
💡 The PowerOne of the most powerful aspects of Apps in Rewst, is that the data within can all be made dynamic by utilising Workflows and Jinja as the backend. If you have no idea what these are, make sure you go run through the Cluck U - Foundation series to get a basic understanding. When you come back, we'll make a simple workflow that utilises Rewst's API!
1. Navigate to the Rewst Platform
Start pretty simply, load up the Rewst platform and you'll see the dashboard
2. Click on Automations
3. Click on Workflows
4. Click on Create
5. Give the workflow a name
Give the workflow a name, something that you'll understand. You can also give it a tag, which we recommend doing to ensure your workflows are grouped together.
6. The Start
We'll start by creating a noop action, which is an action that does nothing.
7. Click on the noop, then the pencil on the right hand menu
Change the name of the action to BEGIN, which allows other users reviewing the workflow to clearly identify the "top" of a workflow.
8. List Forms with Granular Permissions
Next, grab the "List Forms with Granular Permissions" action, which you caan search for. This action is a prebuilt Rewst action that utilises our GraphQL backend to return the requested data.
9. Connect the BEGIN > list_forms action
Connect the two actions together from BEGIN > the new action
10. Publish Result
In the new action, add all_available_forms
as the Publish Results As variable name. This ensures that the output of the action gets added to this variable.
11. Code Editor
Under the params on the action, click the "Edit Code" icon highlighted in the image below
12. Enter Jinja referencing the running user
In Jinja, we can use {{ CTX.user.id }} which uses the ID of the running user, ensuring we always get the right forms based on the logged in user.
13. Advanced Tab
On the Advanced tab, we can amend the "Run as Org" which works in the same way as the Run As User, and ensures that we always run as the org we are logged into. If you have a form that is only enabled for certain orgs, this is how we return the correct ones.
14. Jinja in Run as Org
We add {{ ORG.ATTRIBUTES.id }} into the Run as Org box under the Advanced tab.
15. And another noop...
Let's add another noop and connect our list_forms action to it. We can name this one set_form_output
to make it clear what we're going to do.
16. Add a Data Alias
On the noop, we're going to create a new data alias called form_output
17. Code Editor
Once again, click the code editor icon next to your new data alias
18. The Jinja
We wont go fully into the Jinja here, but feel free to reach out to the ROC if you'd like to understand more what's happening here. The jist of it is that we are looking at all the returned forms, and creating a new key/value dict with name, tags, view and triggerId key. Eventually we'll display the name and tags to the user and use the view key to allow an action for the user - in our case, to go directly to the form. The Jinja can be copied below.
19. Final Noop
Add one more noop into the workflow and call it "END", and connect it to the 3rd action as per the image.
20. Set Workflow Outputs
Next, we need to ensure that the data alias we created actually gets output when the form runs. Click the pencil in the top right of the Workflow Builder, as shown in the image below
21. Add Output Configuration
Click the + next to the Output Configuration and call it form_output
(we can call this whatever we want). In the Jinja, enter {{ CTX.form_output }} - this references the Jinja we made earlier on in the 3rd noop. Remember that one we called set_form_output
?
22. Click on Submit
23. Click on Publish
Save the workflow!
24. Marvel in Rewsty
Click the Rewsty Robo-head and marvel at how we utilise AI to identify the changes made in the Workflow Builder to generate the commit notes.
25. Click on Submit
26. Click on Test
Finally, let's make sure it actually works!
27. Click on Test
28. Click on View Results
29. Click on END
30. Click on output
31. Click on form_output
32. Click on ...
You'll see very similar to the below, where you'll see a list of the forms that have been output! You may not have three, that's fine as it just shows what you have access to.
⚠️ Ooooft!Okay, that was a lot. Building a workflow can be daunting, but if you ever have a problem know that everyone at Rewst wants to help you succeed! If you have had any issues with this, make sure you utilise your Discord private channel and tag ROC Support.
Last updated