Retool Workflows: How to Schedule Changes?

Dmitry Sitnik
Dmitry Sitnik

Head of Low-Code Department

May 23, 2024

Retool Workflows: How to Schedule Changes?

Retool Workflows: How to Schedule Changes?

Retool Workflows: How to Schedule Changes?
Dmitry Sitnik
Dmitry Sitnik

Head of Low-Code Department

May 23, 2024

I believe you agree that usually, we want to have everything now or never. For me, that rule works when I start thinking about having a new gadget, like a laptop, a kickscooter, or even a water filter. If I prevent myself from buying that stuff right away, I will save tons of money – in a week my focus will be changed.

But in the business world, sometimes changes and acquisitions need to be delayed, or better, scheduled. For example, the employee title should be changed starting next month, or the product price should be changed in a week. Let’s track these changes with Retool Workflows!

Real Example

We have recently built an app for a huge international company to manage their employees. Having a way to track and schedule changes was one of the core requirements for this project. The second limitation was that the app should be SOX-complaint, so no unauthorized changes should be made to the data tables, and scheduled changes should be reflected in the database only on their Effective Date. In other words, even if the future change is approved today, it shouldn’t appear on the data table till its effective date, or auditors might be confused with this ‘future’ record.

To handle all these requirements (and a lot of others!), we use temporal tables in MariaDB alongside the Retool Workflows. MariaDB handles ‘basic’ logging in the background thanks to the system versioning enabled. Different employee record card versions are handled by the MariaDB application time periods. However, the approvals and changes are implemented on Retool Workflows. As long as we are going to work with the standard Retool DB, we will modify the idea to work on the basic setup.

Changes in Retool admin dashboard
In this use case, approved changes are scheduled to be processed by a Retool Workflow on their effective dates

Main Idea

So, let’s discuss how we cope with this task in brief. For example, to store the employees data, we have the employees table. This table will store the actual data only. To store the historical data, we will have an additional table called employees_historical. It should follow the original table structure adding effective_end and record_id columns. By the way, the primary key in this table will be record_id.

To store all the changes, we will have the change_requests table. It might have a limited number of columns: id,  target_table_name, target_row_id, change_payload, effecrive_date, and is_processed flag.

Also, one workflow will be needed, let’s call it processChangeRequests. Now we have agreed on what we need to create. Let’s go then!

Employee Card

Let’s start with the Employee Card. The most effective way to create a UI like this is to use the form component. Why? First, it could be generated automatically based on the table data, either in the DB or in the application. Second, it automatically aggregates the individual component outputs to the data property of a form. Third, it allows you to submit data back automatically alongside its validation. If you are new to the form component, take a look at the official documentation.

Funny enough, the third feature is not what we need for this project. While we still require the form to validate itself on its ‘Submit’ event, we do not want the new or updated data to go back directly to the data table. We want to be able to schedule the changes, remember?

The new data coming from the form should go to the change_requests table. To achieve this, we have to construct the payload first. Just look at the picture below: I created a demo form and displayed the requested changes as a stringified JSON in the console.

Emploe card
Instead of firing the SQL request, we wrap the form data to JSON payload

What will be the actual SQL query then?

Something like this:

INSERT INTO change_requests (target_table_name, target_row_id, change_payload, effective_date)

VALUES ('employees', NULL, {{JSON.stringify(form1.data)}}, '2024-07-01');

Just for clarity, what is going on here: we are adding a new row to the change_requests table. We know that the target table for this change request will be employees, we are adding a new employee - that’s why the target_row_id is NULL. As a change_payload we pass the stringified version of the form output. And the effective date is set to July, 1st. Why? Just because I want :) But you obviously will have to create a date input component in the UI to let the user select the desired effective date for the change request.

Inside the Change Requests Table

I’ll show you what a real change request table might look like. The column names here are different, reflecting the real business needs, but the idea is the same.

Change request table
Inside a real change requests table

As you can see, we have different target tables – they are called crs_type_name here. When a workflow fetches the data from this table, it reads this column first – to understand what to do with the data. And remember, you can do it also, that’s why we added the target_table_name column.

The Process Change Request Workflow

Okay, now we are going to examine the most important part here: how to organize the workflow.

The first step is to read the data from the DB. We are interested in unprocessed change requests with effective dates today or in the past. That’s why we run something like this against the table:

select * from change_requests where is_processed = 0 and crs_effective_date <= CURRENT_DATE

The second step is a loop over the returned array. We are going to determine if it is a new record, or if we should proceed with the updating. Also, we should check the table name to know in which table to place the data. A JS code block could help you with this.

The third step, in case of a new record, consists of two actions: we execute an INSERT query against the target_table_name table, and mark the current change request as is_processed running UPDATE query on the change_requests table.

In case of an update, the third step consists of three actions. First, we copy current data to the employees_historical table. This step could look like this:

INSERT INTO historical_employees (id, name, position, salary, hire_date, effective_end)

SELECT id, name, position, salary, hire_date, NOW()

FROM employees

WHERE id = <target_row_id>;

Now, we should update the existing record in the employees table. The data object here is the payload from the change request:

UPDATE employees

SET

   name = {{data.name}},

   position = {{data.position}},

   salary = {{data.salary}},

   hire_date = {{data.hire_date}}

WHERE id = <target_row_id>;

Now we have to mark the current change request as is_processed running UPDATE query on the change_requests table.

Okay, we are done, aren’t we?

Not really. To make the system work, we should schedule this workflow to run, say, every 2 minutes. And then we are definitely done.

A real production workflow might look something like this:

Retool workflow
Inside of a real workflow

Wrapping Up

What have we done today? We discussed a simple approach to implement scheduled change processing. You can use it right away – or modify it accordingly. For example, you can add an app to approve requested changes first, or to cancel the scheduled changes. Or you can add an app to display the different versions of the Employee Record Card.

Don’t be afraid of experimenting with Retool! And remember, we are here to help.

---

Dmitry is the Head of Low-Code Department at Akveo. With a rich background in media and marketing, Dmitry brings an extraordinary look at the world of IT technologies. He is deeply passionate about finding the most effective and elegant solutions to complex client problems. In our blog articles, Dmitry will share his expertise in Retool and other low-code platforms to offer you valuable insights on Retool to enhance business process efficiency.

We already discusses how to use Retool Workflows and how to improve application security. More topics are coming. Stay tuned!

Contact us
Akveo's case

Building Reconciliation Tool for e-commerce company

Our client was in need of streamlining and simplifying its monthly accounting reconciliation process – preferably automatically. But with a lack of time and low budget for a custom build, development of a comprehensive software wasn’t in the picture. After going through the case and customer’s needs, we decided to implement Retool. And that was the right choice.

The scope of work

Our team developed a custom reconciliation tool designed specifically for the needs of high-volume transaction environments. It automated the processes and provided a comprehensive dashboard for monitoring discrepancies and anomalies in real-time.

The implementation of Retool significantly reduced manual effort, as well as fostered a more efficient and time-saving reconciliation process.

→ Learn more about the case

See More
See Less
Akveo's case

Creating Retool Mobile App for a Wine Seller

A leading spirits and wine seller in Europe required the development of an internal mobile app for private client managers and administrators. The project was supposed to be done in 1,5 months. Considering urgency and the scope of work, our developers decided to use Retool for swift and effective development.

The scope of work

Our developers built a mobile application tailored to the needs of the company's sales force: with a comprehensive overview of client interactions, facilitated order processing, and enabled access to sales history and performance metrics. It was user-friendly, with real-time updates, seamlessly integrated with existing customer databases. 

The result? Increase in productivity of the sales team and improved decision-making process. But most importantly, positive feedback from the customers themselves.

→ Learn more about the case

See More
See Less
Akveo's case

Developing PoC with Low Code for a Tour Operator

To efficiently gather, centralize, and manage data is a challenge for any tour operator. Our client was not an exception. The company was seeking to get an internal software that will source information from third-party APIs and automate the travel itinerary creation process. Preferably, cost- and user-friendly tool.

The scope of work

Our experts ensured the client that all the requirements could be covered by Retool. And just in 40 hours a new software was launched. The tool had a flexible and easy-to-use interface with user authentication and an access management system panel – all the company needed. At the end, Retool was considered the main tool to replace the existing system.

→ Learn more about the case

See More
See Less
Akveo's case

Testing New Generation of Lead Management Tool with Retool

Our client, a venture fund, had challenges with managing lead generation and client acquisition. As the company grew, it aimed to attract more clients and scale faster, as well as automate the processes to save time, improve efficiency and minimize human error. The idea was to craft an internal lead generation tool that will cover all the needs. We’ve agreed that Retool will be a perfect tool for this.

The scope of work

The project initially began as a proof of concept, but soon enough, with each new feature delivered, the company experienced increased engagement and value. 

We developed a web tool that integrates seamlessly with Phantombuster for data extraction and LinkedIn for social outreach. Now, the company has a platform that elevates the efficiency of their lead generation activities and provides deep insights into potential client bases.

→ Learn more about the case

See More
See Less
Akveo's case

Building an Advanced Admin Portal for Streamlined Operations

Confronted with the need for more sophisticated internal tools, an owner of IP Licensing marketplace turned to Retool to utilize its administrative functions. The primary goal was to construct an advanced admin portal that could support complex, multi-layered processes efficiently.

The scope of work

Our client needed help with updating filters and tables for its internal platform. In just 30 hours we've been able to update and create about 6 pages. Following features were introduced: add complex filtering and search, delete records, styling application with custom CSS. 

Together, we have increased performance on most heavy pages and fixed circular dependency issues.

→ Learn more about the case

See More
See Less
Akveo's case

Creating MVP Dashboard for Google Cloud Users

Facing the challenge of unoptimized cloud resource management, a technology firm working with Google Cloud users was looking for a solution to make its operations more efficient. The main idea of the project was to create an MVP for e-commerce shops to test some client hypotheses. Traditional cloud management tools fell short.

The scope of work

Determined to break through limitations, our team of developers turned Retool. We decided to craft an MVP Dashboard specifically for Google Cloud users. This wasn't just about bringing data into view; but about reshaping how teams interact with their cloud environment.

We designed a dashboard that turned complex cloud data into a clear, strategic asset  thanks to comprehensive analytics, tailored metrics, and an intuitive interface, that Retool provides. As the results, an increase in operational efficiency, significant improvement in cost management and resource optimization.

→ Learn more about the case

See More
See Less
Akveo's case

Elevating CRM with Custom HubSpot Sales Dashboard

Our other client, a SaaS startup, that offers collaborative tools for design and engineering teams, was on a quest to supercharge their sales efforts. Traditional CRM systems were limited and not customizable enough. The company sought a solution that could tailor HubSpot to their workflow and analytics needs.

The scope of work

Charged with the task of going beyond standard CRM functions, our team turned to Retool. We wanted to redefine how sales teams interact with their CRM. 

By integrating advanced analytics, custom metrics, and a user-friendly interface, our developers provided a solution that transformed data into a strategic asset.

In 40 hours, three informative dashboards were developed, containing the most sensitive data related to sales activities. These dashboards enable our customer to analyze sales and lead generation performance from a different perspective and establish the appropriate KPIs.

→ Learn more about the case

See More
See Less
Akveo's case

Retool for Sales and CRM Integration

See More
See Less
Akveo's case

Building a PDF Editor with Low-Code

Our client, a leading digital credential IT startup, needed a lot of internal processes to be optimized. But the experience with low-code tools wasn’t sufficient. That’s why the company decided to hire professionals. And our team of developers joined the project.

The scope of work

The client has a program that designs and prints custom badges for customers. The badges need to be “mail-merged” with a person’s info and turned into a PDF to print. But what is the best way to do it?

Our developers decided to use Retool as a core tool. Using custom components and JavaScript, we developed a program that reduced employees' time for designing, putting the data, verifying, and printing PDF badges in one application.

As a result, the new approach significantly reduces the time required by the internal team to organize all the necessary staff for the conference, including badge creation.

→ Learn more about the case

See More
See Less
Subscription
Subscribe via Email

Want to know which websites saw the most traffic growth in your industry? Not sure why your SEO strategy doesn’t work?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

By clicking “Subscribe” you agree to Akveo Privacy Policy and consent to Akveo using your contact data for newsletter purposes

More articles by themes

Cross
Contact us
AnnaRodionEvgenyExpertExpertExpert
Cross
Got any questions?
Our domain expert is here to answer
If you have any questions, feel free to leave me a personal message on LinkedIn. We are here to help.
Thanks for your question
We will contact you soon
We have a problem
Please, check the entered data
Got any questions?