How can have a field that can be changed by the user and a formula?

I have a table that has two fields, that the user can change:

  • Stage;
  • Probability.

However if the Stage is ‘Lost’ the probability should be automatic 0 and if is ‘Won’ should be 1.

I setup a trigger on field Probability with an onchange on the field Stage, the formula is something like:

1 if $Deal_Stage == 'Closed-Won' else (0 if $Deal_Stage == 'Closed-Lost' else $Probability)

However I get a circular Reference Error, I guess I cannot set the field to its value.

How can I maintain a field the can be changed by the user and also changed by a formula?

Try the following:

if $Deal_Stage == 'Closed-Won' else (0 if $Deal_Stage == 'Closed-Lost' else value)

The value variable is what the user inserted into the field.

Thank you so much for the help, with the value variable

The code I provided had an error, the one that works is this one

1 if $Deal_Stage == 'Closed-Won' else (0 if $Deal_Stage == 'Closed-Lost' else value)