Add or Edit Record by matching multiple fields

Options
I want to add or edit a record based on the data in multiple fields. 

E.g. I want to edit a record if:
record.id == id AND record.date == date

But, if one of those doesn't match, I want to create a new row where
record.id = id, record.date = date, record.other_field = other_value

Is there a way to do this with the Add or Edit Record interface?
[image.png]

Comments

  • Unknown
    Options
    I don’t think you can use Add or Edit for this use case. You will probably need to use Query All and the use conditionals to edit if the query all returns a record or add a new record if it doesn’t. Not sure if others here have a better solution that can utilise Add or Edit
  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options
    Hey, Connor. For this, I would use an if/then statement. This will check if record-id and record-date equal something, and if so, it will edit an existing record. If not, it will add a new record. Short and sweet.[image.png]
  • Connor McCormick
    Options
    I ended up doing that, but there are some shortcomings:
    1. If then statements take up a lot of space, are slower, and are harder to parse
    2. I have to run a Query + an Edit/Add. If Add or Edit could match on multiple fields then I could do this whole thing in 1 line with 1 query instead of in 4 lines with 2 queries.

    Maybe we can move this post over to feature requests?
  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options
     I'll definitely pass this along and see if I can bring some additional insight back for you. I do think that depending on how intense your logic is, and the volume of your requests, using an if/then for this is as efficient as it can be, especially considering that this is pretty much what would be happening behind the scenes regardless of if it was a conditional built into an Add/Edit function vs building the function stack manually.
  • Puneet Mathur
    Options
    +1 for this request.

    It will definitely make the implementations cleaner and quicker.