Conditional relations that aren't related to the logged in user

Hi community,

I’m struggling with building a conditional relation between two tables, where I can’t seem to find a good link between the two. Coding my solution seems easy, but using glide, it feels like I’m limited.

Here’s my scenario:
I have two tables, one is called projects, the other is called waiting list.

The projects table contains a set of projects admins can build. Each project has lots of data and a “sell price”.

The waiting list is a list of people that want to buy a project. These people aren’t users in the app, just a random list of names. One column in this list is “volume”, which specifies what the minimum price they’re willing to pay for a project is.

What I want to do is build a screen on the projects page which suggests which people on the waiting list could be interested in each project.
Or alternatively: On the waiting list screen I’d like to display all projects that could be interesting per waiting list position.

Now I’ve been trying to build a conditional relation between the two tables, where I’m basically trying to find project matches where “volume” is greater of equal to “sell price”. However I couldn’t find any way to do that. I was only able to set up lookups, but I can’t use any if/else statements with that data. And for building relations I need user data, which isn’t relevant in this case.

Does anyone know how to resolve this?

I’ll try to set up something for you when I have time over the weekend.

Here’s my setup:

Projects table:

Project Name Selling Price
The Parkview 1200000
The Regency 900000
The Summit 1500000
The Riverside 800000
The Heights 1300000
The Estates 1000000
The Villas 950000
The Garden 1250000
The Haven 1100000
The Retreat 1050000

Waiting list table:

Person’s Name Volume
John Smith 100000
Jane Doe 50000
Michael Brown 75000
Lisa Johnson 80000
David Wilson 90000
Robert Taylor 60000
Maria Garcia 85000
James Lee 70000
Karen Davis 95000
Ronald Martinez 65000

Then I use two joined list columns to bring the list of people and their volumes to the Projects table:

Then I use a JavaScript column to process and output the list of people that would be interested in each project.

let people = p2.split("||");

let volume = p3.split("||");

volume = volume.map(function(v){ return parseFloat(v.replace(/,/g,'')) });

let interestedPeople = [];
for (let i = 0; i < people.length; i++) {
    if (volume[i] >= p1) {
        interestedPeople.push(people[i]);
    }
}

return(interestedPeople.join(", "));

Double check

The Regency with a selling price of 900k would attract interest from John Smith (1000k), Michael Brown (900k), Robert Taylor (1500k), Maria Garcia (900k), Karen Davis (950k).

The Garden with a selling price of 1250k would only attract interest from Robert Taylor (1500k).

2 Likes

Hi!
Some no code solution:

  1. In the user Value table you need to prepare Json Object using “Make Json Object”

  2. Lookup this column to Project table

  3. Finish JSON and prepare template for JQ (select if User value > Project Value)

  4. Transform JSON
    This filters values from Json by JQ rules
    JQ there is:
    map - invoke filter foo for each input
    select(value) input unchanged if value returns true


Try to use jq play to play with

  1. Clear results

There no java script, but Glide plugin(Transform JSON) maybe slow your Pages

3 Likes

Thank you! This works like a charm. The only thing I couldn’t figure out now is how I can use the data to display it in a table, rather than just displaying a comma separated list.
I’ve been using Split Text, which does the job on the table side, however I can’t select Split Text columns on the UI. Any ideas?

Thanks a ton for showing this alternative! I went with @ThinhDinh’s solution, however I’ve tried yours as well. I couldn’t figure out step 4 though. Can you elaborate on that one for future readers with a similar problem?

2 Likes

You need help table:
First you need go to details screen, set column current coma separated list to user row (TMP column)
Help table must contain several numbered rows
And template column which retrieve user column-> TMP column(with coma list) to each rows
Then split text the template column
Then single value by row number from spitted template
Now you can set inline list with the source from this Single value column
So, you will transposes text coma separated list to help table single value column

The split text returns an array and is mostly unusable for displaying purposes, except the kanban layout in Pages, where you can use it in the “Tags” field, I believe.

Just curious, what do you expect to see when you want to display an “array”?

1 Like

May be, when we see the coma list of results and can convert it to inline list inside details, in this case we can tap one of to deal next

May be, when we see the coma list of results and can convert it to inline list inside details, in this case we can tap one of to deal next

Yes, that’s exactly it.

Do you clear about solution?

I’m not following this thread very closely, but when you have an array from a split text column, you can then create relation using that array, and link it to the appropriate table. That relation can be used as the source of a list.

3 Likes

Thanks to Jeff!
It is a good idea that don’t use helper table to transpone array to row but use relation!
But relation must be from array to target! Exelent!

1 Like

Thank you, that resolves my problem :slight_smile:
Thanks everyone involved!

2 Likes

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