Complex Data Operation

Hi all - I’m looking for some ideas on how I might create a complex operation on some data in a collection.

I have a few options but looking for advice from anyone who may have worked through this already. My objective is to be able to iterate through a set of items in a collection and then for each item make a decision based on some business logic and then subsequently update each item.

I think my options are:

  • Create a custom component (complicated and I don’t know much about react)
  • Create an API hosted elsewhere that is called by a custom action in Adalo passing in the core data elements

I think that the second option sounds better and then I can use the inbound data to subsequently call the Adalo API and work through the logic I need. I’m not quite sure how to manage the security when Adalo calls my API but I can work through that.

I’ve had a look at the approach @Victor uses to loop through a collection and makes updates but I think the logic is too complex for this approach. I’m also not a fan of how it presents an interface to the user while it processing and updating records.

Any input, feedback or experience anyone would like to share?


Hi @berwickgeek ,

My understanding is you want batch processing, so you can loop to do things.

If you go for option to call collections api, you need to consider rate limit, if you go for backend processing, it is limited in function and will be using external collections too.

The only way to do in internal collection is through countdown component that are heavily been explained in numerous times.

Adalo can handle complex logic, only to view them in whole screen is difficult because actions are close by default and to open it means close the current action and only 1 action can be opened at a time, probably because no code label, so it looks somekind of easier, but for more conditional and branches it can challenge our patient. :grinning:

1 Like

Hi @berwickgeek,

Each approach should be used in a proper way :wink:
Countdown timer works in simple cases (say, 5 - 15 records), but if you have 100s of records it becomes unreliable (as it is executed on the client side).

For more complex stuff, I’d advice to use Integromat for data processing - it can access Adalo collections via API. Though this might cost some $$ (as they charge per number of credits, and each operation consumes 1 credit). Of course this depends on the scenario, frequency, complexity, etc.

As an alternative to Integromat, you can set up external functions in AWS Lambda or use Google Cloud Functions, but this requires some knowledge of programming.



I’ve spent a few hours building out the logic I need in python with the intent of hosting it in AWS lambda. The roadblock I’ve now hit is dealing with relationships through the api appears not to work.

I’m pretty frustrated that after spending the time to work through this that the roadblock is the api. Doesn’t make sense that you can do an update from the Adalo interface but not the api. Anyway…

I’m not sure where to turn with this now. I feel I’ve reached the end of Adalos capabilities which is such a shame as the actual build of the rest of the app took a fraction of the time it would have taken in any other platform.

Hi @berwickgeek ,

Well if you explain a bit more about the logic you need to implement, someone may give an advice:)


Just an idea, you could add id as numeric for every collections that you want to have relationship with, so updating them will be through filter for this id.

These ids will be unique and present in both of collections that are in relationship.

1 Like

I’ll try my best to explain.

It’s a little like a fantasy football league. From a list a potential players you rank your selection of players from 1 to n.

Let’s say there’s 3 users and 10 players. So each user ranks the 10 players from 1 to 10.

All of the above is doable in Adalo so far.

Now comes the actual pick (and the problem). After all users have ranked the players I want the app to randomly sort the users and then get the next best player pick from each user’s ranking and assign that player to that user. Each player can only be assigned to one user, so as a player is picked it must be removed from the other user’s ranking.

I’ve written the logic in python to do all of the above and it uses the Adalo API to grab user information and player information, cycles through everything and I end up with a set of players and which users should be assigned.

In Adalo I have the following data structure:

  • Users
  • Teams (to group the players)
  • Players
  • Rankings (where the user ranks the players)

Users have a 1 to many relationship to Rankings
Teams have a 1 to many relationship to Players
Players have a 1 to many relationship to Users
Users have a 1 to many relationship with Rankings
Players have a 1 to many relationship with Rankings

The goal is to update the reference to the user on the Players collection based on the ranking logic.

I’ve just read @Yongki’s comment and you’ve given me an idea. Rather than having a relationship between Players and Users I could just populate the information I need into the Players collection for each user. It’s messy and goes against everything I know about data structures… but it might work.

From my understanding, this can be done inside Adalo.

If you have an example before and after picking, I can then see your logic.

@Yongki I’m interested to know how you think this could be achieved in Adalo?

To be clear, I don’t want a user going through and assigning users to players, I want the logic in the app to do the assignments automatically based on the randomised users and the ranking applied to the players.

The above shows:

  1. A player with no assigned user
  2. A player assigned to a user

This is how I’ve related a player to a user:

Can you elaborate about this ?

Sure. After all users have ranked their players, the owner of the team will then start the automatic picking process.

In this process:
The users are randomly sorted, like flipping a coin so that you don’t know who gets first pick.
The following logic gets looped through for for the number of times that there are competitors, so in this example, 10 times:

  • Find the highest ranked player for the first user
  • assign the user to the competitor for that ranking
  • remove that competitor from all rankings for all users, so it can’t be picked again
  • move onto the next user

So if there’s 10 competitor and 3 users the the above process executes 10 times and every user gets their highest allocated ranking in a fair way through the random order of the users. In this example, one user gets an extra selection… but that’s fine.

It’s complicated, I understand that, and hard to explain as it’s taken time just to work it out in my head.

Just need clarification,

By “competitor”, you mean player, right ?

for every user, the selection process will find the highest ranking, so if we get the highest, we can ignore the 9 players, right ?

Yes - Competitor in Adalo = Player in this discussion.

Sort of. It loops through the users for each player.

Here’s a sample data set of rankings before the process starts:
Ranking for user 1
User 1 Competitor 1 Ranking 4
User 1 Competitor 2 Ranking 1
User 1 Competitor 3 Ranking 3
User 1 Competitor 4 Ranking 10
User 1 Competitor 5 Ranking 8
User 1 Competitor 6 Ranking 9
User 1 Competitor 7 Ranking 2
User 1 Competitor 8 Ranking 7
User 1 Competitor 9 Ranking 6
User 1 Competitor 10 Ranking 5

Ranking for user 2
User 2 Competitor 1 Ranking 6
User 2 Competitor 2 Ranking 8
User 2 Competitor 3 Ranking 3
User 2 Competitor 4 Ranking 10
User 2 Competitor 5 Ranking 1
User 2 Competitor 6 Ranking 9
User 2 Competitor 7 Ranking 4
User 2 Competitor 8 Ranking 7
User 2 Competitor 9 Ranking 2
User 2 Competitor 10 Ranking 5

Ranking for user 3
User 3 Competitor 1 Ranking 10
User 3 Competitor 2 Ranking 8
User 3 Competitor 3 Ranking 3
User 3 Competitor 4 Ranking 6
User 3 Competitor 5 Ranking 1
User 3 Competitor 6 Ranking 2
User 3 Competitor 7 Ranking 4
User 3 Competitor 8 Ranking 5
User 3 Competitor 9 Ranking 7
User 3 Competitor 10 Ranking 9

When the pick occurs, assuming the users are randomly ordered as 2, then 1, then 3:

  • The highest-ranked competitor for user 2 is competitor 5, so User 2 is assigned to competitor 5
  • The highest-ranked competitor for user 1 is competitor 2, so User 1 is assigned to competitor 2
  • The highest-ranked competitor for user 3 is competitor 5, but this competitor has already been assigned to user 2, so the next highest-ranked competitor for user 3 is competitor 6, so User 3 is assigned to competitor 6
  • Now we go back to user 2 (and keep looping through the users in this way).
  • The next highest-ranked competitor for user 2 is competitor 9, so User 2 is assigned to competitor 9
  • The next highest-ranked competitor for user 1 is competitor 7, but this competitor has already been assigned to user 2, so the next highest-ranked competitor for user 1 is competitor 3, so User 1 is assigned to competitor 3
    …and so on until all competitors are assigned to a user

I get it, let me cook a sample app for you.

1 Like

Hi @berwickgeek ,

Take a look at this cloneable app,

There are some bugs or preventions that need to be placed and solved, but the whole operation bring the expected result.

Let me know if it does not suit you, but better after revising the ranking collection with your data.

To start, click clear competitor’s pickup and to begin iteration, click pickup competitor and to do another iteration click again.

This is to show the basic operation and still need a lot of adjustment/revision to make it smooth and reflect your database layout.

Hope you find this as a start.

1 Like

Hi @Yongki

Firstly - thank you for taking the time to do this. I truly appreciate it and I’m really surprised that anyone on a forum like this would go to the effort you’ve gone to. So again, thank you.

I’ve cloned the app and reset some of the data and I’ve been able to get it to function as you’ve explained here and - it works!

I can see the logic of moving through the three screens over and over until all the picks are done. That makes sense and isn’t something I’d seen until now.

I’ll need to spend some time reviewing the logic in each list and the updates you’re making to various fields and how the lists on each page change based on those updates, but I’m confident I’ll be able to work through that.

I really am surprised that the logic is able to be implemented. I think I can clean up the screens and put some lottie animations in place so the user has something to watch while it’s all happening.

I imagine it’s hard to translate something that’s in your head onto the page (browser?) so please don’t feel you need to spend any more time on this and I’ll work through it progressively.

Thanks one more time.


1 Like

Hi Jay,

Glad that you like it. :grinning:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.