Automate simple things can save you a lot of time in youy business.
Today we’ll use WayScript to create a script to Process Data with Java and Write to a SQL Database.
In this article, we’ll register in a SQL database all
create cards> action in a Trello Board.
No prerequisites but some content you might find helpful:
As I said earlier, we want to register in the SQL database all
createCard. WayScript provides a Trello Trigger we can use to follow up events we are going to specify, and use the data in the responses to make our script work.
Add it as a new Trigger.
Once it’s added, we can configure it.
Once you’ve selected the board, be sure to have the following outputs selected too.
Good, now we can move to the Java module.
We’ll use Java code to perform some actions on the data returned by the trigger. Our goal here is to return a boolean which will be True if the action on the board is
createCard, then run the SQL script. Add it as a new Step.
Once it’s added, click on Edit Code.
- Line 3:
WayScript.variablesis a dictionary containing all variables in the current script. We get the action type value that we convert to a String object.
- Line 5: If the action type is
isCreateCardvariable is true.
- Line 9: We can also output data from the Java code, that will be used by other modules. We first specify the name of the variable we want in the script, followed by the variable of the Java Code.
We have a boolean value available in the script. We’ll use If modules to make comparisons and guess what, it’s very simple.
By using the If condition, we can make simple comparisons and decide on the behavior of our script.
Add If module as a new step.
Once it’s done, we can set the conditions now.
Now, we have two branches. An If branch and an Else branch. If the condition is true, the script in the If branch will be executed, otherwise it will be the opposite.
We’ll add the SQL module in the If branch then.
We can now write SQL queries.
Great. We’ve nearly done. Be sure to have the Trello turned on and now your script is ready.