Optimal Run Workflow on a List approach

I have 2 databases.
Trips and Orders.
Trips can have multiple orders on themselves.
Orders have ID - which can be the same on more orders (as this one is not the unique ID I use).

How to run workflow on a list of trips to target only those trips which contain any of the order with ID XXXX?

As when I run workflow on the list:
Do a search for trips where:
Filtered: Advanced → This trip orders intersect with do a search for orders : where ID = Text.
But somehow bubble triggers me to select yes or no - where it clearly is yes or no in that case.

How to approach this many to many searches? I know I used to have this challenge with overlapping 2 sets of options where I wanted to look for situation where anything overlaps between 2 data sets, and was stuck there.

Do search for trips with constraint Order contains Selected order.

But I am not checking vs selected order, but vs selected orders. There are many orders with this ID. The ID isn’t unique and it refers to many elements.
Example
Order A - ID 1
Order B - ID 1
Order C - ID 1

Trip X1 has order A
Trip X2 has order B
Trip X3 has order C

I want to list all the trips containing orders with ID 1. And Orders don’t have trips, tripls have orders.

OK - Got the solution which makes me very sad as it’s double filter on large dbs. Gonna be terrible in performance :frowning:

Do a search for trips filtered:
Advanced Do a search for orders filtered:
Advanced This order ID is Text.

But it means it collects 2 humongous databases to just find 3 items at max and 1 at min.

//Added some constraints on the first search to make it more bearable but still this is an issue.

Okay, so set a field on trip to be of type text and just make it be in sync with the ID field on the Order data type so you can simply Do a search for Trips whose ID field is in Selected Orders each items ID…since a single trip has only a single Order and a single Order has only a single ID

1 Like

As mentioned, you can add fields to link things to each other.

Alternatively create link-table datatypes that link different datatypes, then you can just search based on multiple linked data. It may require some syncing to keep the links updated but your nested searches will blow your WUs in not time.

2 Likes

The case here is that the trip can have multiple orders. The case just shows where the order is. So all orders appear only once, but they are not always alone on the RT. So could have added that in my case example.

They are already blowing 75% of application power. But case I have is - when multiple backend workflows can kick in simultaniously i am afraid to calculate sums as they may lead to wrong numbers. I never have the end of the trip as a cost update can come anytime.

So you recommend to have a link table for that… I can also save the sums on the trip - so I will have revenues and costs as numbers - then calulcating the margin would be easier.

What are the things to watch for in that case?

Yep. Your link table is like a receipt. One look and you’ll have the whole picture.

  • If you go with link tables just make sure you have workflows to update them when necessary.
  • Most others will also recommend putting these syncing workflows in a backend WF.
  • If you need absolute certainty that values are passed correctly, break WFs into smaller Custom Events and pass/return parameters.