Trying Ternary for the first time as a 'middleware' type action from API data

HI all,

As some know, I’m building a complex search function in Wappler via our ElasticSearch services API.

This is what I’m not trying to achieve:

  1. Return records from the end-users search.
  2. Check records returned against a specific table in our DB.
  3. This DB holds conditions, e.g. ‘display email address’ Boolean field.
  4. If the DB table ‘display email address’ boolean field is ‘true’ then on that specific record in the repeat I display the email address. If it is ‘false’ then I display a ‘reveal’ button. This then triggers a new workflow, if the user clicks reveal.

So far, I have the following working:

  1. ES Search returning results and rendering in a repeat on page fine.
  2. I then have a Set Value action that returnes all unique ID’s of each individual record returned in an array.
  3. I then have a DB Query that uses those ID’s to return data from the DB.

The part I’m now stuck with is applying the correct ternary (or other) to each dynamic record in the repeat based on the match in the DB.

It’s REALLY important that we cannot have sensitive information being displayed in the code and ternary seems to serve this process, as it appears to only displays the output, not the full code including the two variants.

I’ve tried quals and contain formatting functions, referencing the repeat group unique ID against the DB Query output, and vice versa. I’ve tried contain in array. And I’ve also tried various ternary scenarios but can’t seem to get anything to show the correct output.

Here is an example, I feel I’m close but not quite getting it so would appreciate any help here! @Teodor would love some guidance from you here.

{{DataForm.data.query1.groupBy(`external_id`).contains(_id) ? 'showemail' : 'noshowemail'}}
Community Page
Last updated: