Is there a way to make an autoenter field (replaces existing field contents) NOT update?
Check the "do not replace existing value" option.
Thanks, but in many circumstances I DO need it to update. That's my problem--I need it to update, just not in this specific circumstance.
I was hoping you weren't going to say that.
You're going to have to enumerate all the circumstances it needs to update and trap for them.
In your calc you could try adding the expression...
Field1 ≠ "Value" ; Self ;
Field1 = "Value" ; Field2 * 2 ;
... but the option to return Field3 is logically impossible. That could be because your sample code is simplified.
By "enumerate all the circumstances" I mean you're going to have to identify each possible variation of fields and values and code accordingly. It can become complicated quickly.
So if Field1 can have 5 different values, make an expression for each that specifies what the output should be. If The output also depends on values in other fields then you'll need an expression for each of those options.
What about Field3?
If you want to update only when Field1 is changed,
If ( Field1 = "Value" ; Evaluate("Field2 * 2") ; Evaluate("Field3") )
Evaluate ( "If ( Field1 = \"Value\" ; Field2 * 2 ; Field3 )" ; Field1 )
It is simplified.
I've tried Self in a few ways and it always just created a different problem, but maybe I need to work through it some more and change the order of the conditions around.
Category = Category1 or Category = Catgory2 ; RetailPrice * 0.5 ;
and not everything is in the pricing table, nor will it ever be (the company I'm working for sells lots of one-off items).
So, if the item is Category1 or Category2, calculate cost from retail. Otherwise, use what's in the pricing table. Unless there's nothing in the pricing table, then just take whatever gets typed in. But if they change the product, cost needs to reset based on the criteria. If they change the retail, it does NOT need to reset, unless it's in Category1 or Category2.
I inherited this calculation from a previous developer and this is a client's database, so I have no input on the business processes unless there is literally no way their database can do what they're asking.
Hmm, I was thinking about Evaluate, but I couldn't quite think of how to do it. I'll have to try this. Thanks!
seems like you should not try and pour this into an auto-enter calc but build it into the scripted workflow to set that field. That way you are in control instead of FM events.
The scripted approach may be your best option, but I will share one observation just in case it provides a non-scripted approach that works for you:
Referring to your original, simplified expression, if Field 2 were located in a record from a related table (this can be a 1 to 1 relationship if needed), changes to the value of that field would not trigger an automatic recalculation. Of course, this means that changes to field 2 never cause an update to the field's calculated value, but you can always either use a script to update when this is needed or modify a field referenced in the calculation that is in the same record when you need to "trigger" a recalculation.
Thanks everyone for your help. I feel like I have a few solid options to try out (including moving it out to a script). I'll come back and update once I get it worked out. Thanks again!