model conditions to only apply for new rows

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a use case where I'd like a model to create a new row if one doesn't exist, but load an existing row if it does exist. So far so good.
I need to have certain conditions applied only when the row is created (but not be part of the query)... conditions like Date__c = 'TODAY' and Nurse__c = (userinfo)(Name).

What's the best way to handle that?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Not quite sure I understand what you mean by conditions.  Do you mean default those specific fields to the values you specified in the question?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Yes. Which is what conditions do during row creation.

Looks like a model action triggered by new row creation with a bunch of update field on row actions will do the trick.

Is there an easier/better way?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
This is what I'd suggest.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Or snippet.  Snippet has the advantage that you can leverage logic, otherwise, stick with the AF.  Anyone else care to weigh in?