Okay so we came across a scenario that caused a bit of an argument:
a!localVariables( local!varA: a!refreshVariable( value: rand()*100, ), local!varB: a!refreshVariable( value: local!varA, refreshAlways: true ), a!sectionLayout( contents: { a!integerField( label: "Changes in this should change Var B", value: local!varA, saveInto: local!varA ), a!integerField( label: "What happens here", value: local!varB, saveInto: local!varB ) } ) )
Obviously this is a terrible idea in practice, however if we can put this aside the real concern is that when you do this changing the value of varB the change somehow back propagates into varA, how is this happening? Is varB just a shallow copy of varA and vice versa?
In other not news, your site breaks every time I click on the tags box.
Discussion posts and replies are publicly visible
The inline documentation for a!refreshVariable states:
refreshAlways (Boolean): When true, the value of this local variable will be refreshed after each user interaction and each interval refresh. Because the variable is continually refreshed, you cannot update its value by saving into it. Default: false.
Clearly the bolded text is not being enforced, but I'm guessing that's what's driving some of this behavior (i.e., you're not supposed to be doing this to begin with, so unexpected behavior may occur.)
Notice that varA doesn't need to be a refresh variable itself. You can remove your refresh variable definition in lines 2-4 (still keeping varA there) and you'll see the same behavior. Moreover, you can move varA to a load() outside of a!localVariables and you'll still get the same behavior.
Yeah I was expecting the same error you see when you save into a time refresh var.
Fun fact if var A is time refreshing you do get the error when saving into var b.
Interestingly, with just a small change to the definition of local!varB, the form starts behaving how I would expect (i.e. refusing to saveInto directly into varB).
For example:
a!localVariables( local!varA: a!refreshVariable( value: rand()*100, ), local!varB: a!refreshVariable( value: local!varA + 2, refreshAlways: true ), a!sectionLayout( contents: { a!integerField( label: "Changes in this should change Var B", value: local!varA, saveInto: local!varA ), a!integerField( label: "What happens here", value: local!varB, saveInto: local!varB ) } ) )
Seems like a deep/ shallow copy issue maybe?
Appian Java code reads the first scenario as varA=varB and creates a shallow copy, and it reads the second as varA = varB+2 and creates a new object?
That's how it seems - or at least, it notices some difference between the object created directly from another object, versus by an expression (local!varA+2).