Skip to main content
Logic Action

Use the logic action to trigger data manipulations from user driven events.

Justin Yan avatar
Written by Justin Yan
Updated over a week ago

In Frontly, the Logic action enables real-time data manipulations based on parameters set by you, the app creator. This is an incredibly useful tool which allows dynamic, responsive applications that can adapt to user inputs and changing conditions, enhancing the app's functionality and user experience.

There are currently two logic operations available, with plans to expand further over time. The existing operations include "add to comma-separated string" and "remove from comma-separated string," which allow adding and removing defined static or dynamic values, respectively. Actions like these makes the flexibility of managing and updating some your data sources efficient and straightforward.


Use Cases for Creating Logic Actions in Frontly

Using the existing operations of this action (so far), here are some real life use cases for them that could be useful for an app.

Like System

Create a 'Like' system where listed objects can be 'liked' and filtered to create another view of all previously liked objects.

Tagging User / Organization Profiles

Update user profiles by adding or removing tags based on user behaviour, such as adding "premium" when a user subscribes or removing "trial" when it ends.

Event Management

Track participant lists for events by adding users to an attendee list when they register and removing them if needed.


Setup Overview

There are two important steps to completing any logic action within Frontly.

Preparing the Operation

Note that the "add to comma-separated string" and "remove from comma-separated string" operations have similar setup fields.

Within the logic action's configuration modal, here are the fields to consider:

List: An existing value or set of values that these operations will be applying itself to. This can be a static value, but it is more often than not a dynamic one.

Value: The defined value or values that will be added or removed through the logic action, depending on the operation selected. This can be a static or dynamic value as well.

The 'Unique Values' switch that appears for the 'add to comma-separated string' operation, if turned on, will not append the value to the array if the value already exists in it.


Registering the Output

After determining how the logic action will function, you need to decide where it will be used. Since the logic action only sets the context to start an operation, a follow-up action is almost always necessary to complete it.

Whether it is to update a local state, an active user, or a record in a data source, these respective actions must be defined in your action flow while referencing the logic action through the 'Action Steps' variable, as shown below.


Example: Creating a Like System

This real example follows the configuration displayed in the the 'Real Estate Listings' app template. This template can be accessed and downloaded from the link here.

As shown in the 'Like System' example above, you may have a set of listings that includes a heart icon that can be clicked by your users to 'like' them.

Behind this click action you'll have two actions: 'Logic' and 'Update Active User'.


Logic Action

Let's break it down what you'll need to fill out and what you'll try to to achieve through this action.


Operation: Add to comma-separated string

We want to add a value to a pre-existing value or string of values

List: {{ user.liked_properties }}

As part of this app's setup, we have a custom user field, 'Liked Properties', which is a string of comma separated ID values, each correlating to a different property, connected through an existing relational data setup.

Value: {{ record.frontly_id }}
The value we want to pass into and append to this list of 'Like Properties' values are the Frontly IDs of the listed items that have been liked by the user.

Unique Values: Toggled On

After a value has been added to the list of user liked properties, there is no need for its value to be added more than once if clicked again.


Update Active User Action

Designate the field where the liked property record values will sync into and use the 'Previous Step' / 'Action Step' variable to reference the logic action wherever it is in the action hierarchy.

Once this setup is complete, you can now use the updated values to perform a myriad of other useful tasks around your app. With the user liked properties values now updating dynamically in the backend through logic actions, you can set up similarly dynamic UI processes such as real time filtering and responsive 'like' and 'unlike' widgets (with the added help of block versions as well).

Have fun creating these processes in Frontly with this new action type!

Did this answer your question?