Explained: create a 1:N relation and filter chosen items out

Dear fellow-Creators,

I’ve twisted my head around something for a while, which is how to be able to create a 1:n relation in Triggre, but filter the already chosen items out of the list with ‘items to choose from’.

In my case, I’ve created an application for IT service suppliers, which has an user-flow which is based on the datatable ‘Request’. Each request can have, for example, multiple drives, printers, applications etcetera, which are stored in datatable ‘RequestDrives’, ‘RequestPrinters’, RequestApplications’ etcetera.

So what I’ve done is this:

You first got a page, button and flow part where you create a Request of course.

Then afterwards, you’ve got a button which sends you to a page like this:

We’ve got a dropdown/select where we can select one organisation from datatable Organisation.

If we’ve chosen an organisation, you can add the organisation by clicking the button ‘add organisation’, which triggres the flowpart ‘create RequestOrganisation’, which has got the inputs ‘Request’ and ‘Organisation’ where Request is the created Request and ‘Organisation’ is the selected Organisation in the dropdown/select.

Now, the trick is to filter the already selected/chosen organisation (see the records in the table ‘Gekoppelde organisaties’) out of the dropdown/select of ‘Organisation’, so you prevent users of creating unnecessary double records:

https://prnt.sc/rfx6o5

This is done by using the following filter (credits to Jochem for helping me out on this one):

  • Use a function which checks if list A contains B
  • So we’ve got a function which is:
    • LIST Request/RequestOrganizations/Organization CONTAINS Organization = FALSE
      • Where the LIST is the Request from the userflow, then the linked RequestOrganizations (which is linked in de datamodel), en then the ‘Organization’ which is linked.

      • Where the ‘Organization’ of the ‘CONTAINS’ part is simply the ‘Organization’ property ‘Organization’

      • To clarify, you need the = FALSE statement, because you’re checking whether the organizations shown in your dropdown/select IS NOT in the list of already linked RequestOrganizations of this Request.

If you found this helpful, please let me know by hitting the +1, it might stimulate me to share more of these tricks.

If there’s a question about something, let me know and I’ll try my best to respond to your question.

1 Like

Thank you for clear explanation. It’ll be appreciated!