Create a Workflow to utilise in your App
Last updated
Last updated
Feedback
⬆️ CannyCopyright © 2024 Rewst
💡 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!
Start pretty simply, load up the Rewst platform and you'll see the dashboard
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.
We'll start by creating a noop action, which is an action that does nothing.
Change the name of the action to BEGIN, which allows other users reviewing the workflow to clearly identify the "top" of a workflow.
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.
Connect the two actions together from BEGIN > the new action
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.
Under the params on the action, click the "Edit Code" icon highlighted in the image below
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.
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.
We add {{ ORG.ATTRIBUTES.id }} into the Run as Org box under the Advanced tab.
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.
On the noop, we're going to create a new data alias called form_output
Once again, click the code editor icon next to your new data alias
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.
Add one more noop into the workflow and call it "END", and connect it to the 3rd action as per the image.
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
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
?
Save the workflow!
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.
Finally, let's make sure it actually works!
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.