if statement...calculate value if true, leave as existing value if false

533
6
08-05-2022 10:41 AM
PaulPetersen1
Occasional Contributor

I have an Inbox workflow where I am editing existing data in the Survey. If a certain condition is met via another survey question, I would like to force-calculate a new date (now()) into a hidden attribute. If the condition is false, then I want to keep the existing date that was downloaded with the form.

Any ideas of how to accomplish this without creating a circular reference? I've tried a few things with Relevant, but when the condition is not met, it nullifies the question, whereas I want to keep the previous value intact if the condition is false and only fire the calculation if the condition is true.

0 Kudos
6 Replies
DougBrowning
MVP Esteemed Contributor

As you saw you can't say do this or leave it.  Usually the trick it to use 3 fields.  Have the current value, the new value, and the 3rd with a if to pick the one you want.  In your case OriginalDate, CurrentDate, FinalDate (I think if you are using now then maybe can get away with two).  if(something, OriginalDate, now()).  Set the temp field to bind esri null and the user will never even see the trick.

Hope that helps

0 Kudos
PaulPetersen1
Occasional Contributor

Hi Doug,

I've tried something like that, but am getting a circular reference error.  The problem is that when the form loads, I have the calculate the value into the bind esri null OriginalDate field...from the FinalDate field, which is permanent schema.

So I guess I'm trying to find a way to populate the "original" date null attribute from the existing value when the form loads, and then update the same existing value if the condition is met, without creating a circular reference.

0 Kudos
DougBrowning
MVP Esteemed Contributor

You may have to store that original field if using inbox.  You can hide it from them on the web map side so they still won't see it.

I personally would have it as a second form, I don't like people editing the same doc but I understand.

0 Kudos
PaulPetersen1
Occasional Contributor

Thanks Doug. I'm just trying to write the date value of a related Inspection (repeat) into the parent table for the sake of symbology and tracking inspection cycles. Given the complexities of doing this in S123, I may just strip those fields out of the parent and set up a SQL Query View instead that links the assets to the inspections, and register that to a map service...that should effectively achieve the same goal.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yep symbology is the kicker on that.  You can get the value in arcade but cant symbolize it.  For these I tend to go old school and just run a script each night to populate the parent.  It used to be a join was a one time deal but I think a view can do this now.  Assuming hosted here but sounds like you may be SDE.  If it is I would then look at the new Attribute rules for this.  

Hope that helps

0 Kudos
PaulPetersen1
Occasional Contributor

Yeah, SDE with Portal 10.9.1. So hosted views, while very cool, are out the window (as I learned earlier today). But that's ok...writing a SQL Server query view to join and summarize all my related tables and then registering it to the geodatabase, then publishing as Map Service to consume in my web map and dashboard is pretty quick and effective.

I'll check out the attribute rules for the future, thanks for the tip.