Search Action code to return a matching record versus an array of records

  • 17 April 2022
  • 0 replies

Userlevel 2

I’ve had good luck getting code tips from the brilliant people in this community so here goes.

I’m building a Search Action for an app which has an API with only two GET endpoints, one that gets all records for an object and one that gets a record by ID. I want this Action to find and return the record that matches a field in the my trigger, and if not found, create a new record.

Here’s my current API request, which returns all records for the object in an array.

Rather than returning all the records, I’d like it to parse the results to find the record in which the field “fruit” matches an input field “fruit” that will contain value “banana” that will come from the trigger, and return only that record (or even just the id of that record since that is all I need in subsequent steps). If no matching record is found with banana as the fruit, I want it to return whatever result will then allow it to use the Create Action that I will have paired with this Search Action.

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.