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
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).