Unexpected behavior of RANDBETWEEN ()

I have an application that uses the following expression in Init Value:

        ISBLANK([Garantía Id]),
        (DATE([Ult. Ingreso Gtía].[Retirado Fecha])+[Ult. Ingreso Gtía].[Días Garantía])<TODAY()
 MONTH(TODAY())&(YEAR(TODAY())-2000)&RANDBETWEEN(1000, 9999),
 [Garantía Id].[Nro Orden]

I copied the app to make modifications, and one of the modifications was to put the following in Editable If

[Cliente Id].[Part/Gremio]="Gremio"

I don’t know if that was the cause, but in the original app the result of RANDBETWEEN () is fixed, while in the other it is updated every time another field is modified, as if Reset on Edit were enabled, but it is not.
I compared the column properties one by one, and I find no difference, I even added in the original app the expression to Editable If and it still behaves as it should.
What can be the cause of this behavior?

So the Initial value expression is being reevaluated and updating the column value every time the row is updated?

No, this happens before adding the record.
In the form, while in the original app, the value remains fixed, in the copy the value varies each time a field is filled.

1 Like

I would expect RANDBETWEEN() to produce a new value each time the expression is evaluated. The expression would be reevaluated each time any of the column values referenced in the expression changes. If you’re seeing different behavior from the same expression in different apps, I have no explanation for that. :frowning:

1 Like

I recorded a video of each app.
You can see how the [Nº de Orden] field does not change when drawing successively in the signature on the original app (Light) and it does change on the copied app (Dark):

Original app (no changes)

Copied app (Nº de Orden changes)

1 Like

I don’t know why the two apps behave differently. I’m going to have to refer you to support@appsheet.com for a deeper look at your app.

Attn: @Aleksi

1 Like

@Alfredo_Pou May I ask what happens if you try just RANDBETWEEN(1000, 9999) as an initial value? Is the behavior the same then?


Yes I suppose it would work, because I solved it by creating a virtual column that contains RANDBETWEEN (1000, 9999) and replacing this expression with the virtual column.
I understand that having an IF, it is evaluating it with each change.
What surprises me is the difference in behavior between both applications, being that I copied the expressions, to make sure that I had not made any mistakes.
Artificial Intelligence Issues …

But if you use just RANDBETWEEN() with the initial value, does it change it when you update the drawing?