Collect records and search records in the same automation // how to address?

I have a call records app. For each missed call I look if there is another call that returns the missed call:

  1. get missed calls from a view (collected records)
  2. for each collected record, check if there is a record that returns the call (limit to 1).

Now when I update the collected record from step 1 with data from step 2, I seem to have no native way to differentiate between results from 1st and 2nd step?

Or do I now think enough about it?

Unfortunately, I don’t believe this can’t be done in a purely no-code way because the second collection step overwrites (or merges with) the results from the first collection, making it impossible to differentiate between them.

Since you’re likely getting multiple missed calls from a view and then looping through them, you’ll need to:

  1. Build an array of all the record_ids from your first collection into a var variable at the start - something like:
   var_records = jsonata('record_id[]').evaluate(record_collection_appName)

The [] after the record_id means that JSONata will deliver an array of record ids even if there is only one
2. Loop through that var_records array
3. For each record_id in the loop:

  • Search for the returning call
  • Use tape.record.update() with the current record_id to update the missed call record
  • Clear the collection

This way you’re not dependent on the collection that gets overwritten during each loop iteration.

3 Likes

I think maybe the logic could be reworked a bit. What is the current trigger for your flow? If I were setting this up, I would have a relationship field in your calls app, “Returned call”. Then have your flow trigger on call record create. Search for a missed call from the contact number that does not have a return call linked to it, and if found link the triggering call there.

Now with this setup you can still do your flow above if needed, but you can more easily see if your step 1 calls have a returned call, because that relationship field will be empty. You could even have a filter in the app for missed calls that have not yet been returned.

Could that work?

8 Likes

That sounds pretty smart :wink:

1 Like