I’m not sure if this qualifies for the best practice or not, but I never use AddOrModifyRows()
. Instead I’m doing this explicitly with an IF:
If(
thisTable.Filter(...).Count() = 0,
thisTable.AddRow(...),
thisTable.Filter(...).ModifyRows(...)
)
This would also give you more flexibility should the match conditions change — e.g. you don’t just want to match whether the row exists by this and that column, but e.g. when you’re already looking up that thisTable.Filter(...)
part into this row (perhaps with a complex condition that you don’t want to copy over) and your formula would simplify to just
If(
LinkedItem.IsBlank(),
SomeTable.AddRow(...),
LinkedItem.ModifyRows(...)
)
which is a pretty common scenario in my experience.
P.S. Actually it is going to be one of the best practices. Linking data via lookups is generally a good practice, so it only makes sense to reuse the linked (looked up) item or collection of items within the If(IsNotBlank(), ModifyRows(), AddRow())
idiom.