Is it OK to use this approach for conditional multiple rule input saving on button component?
a!buttonWidget( label: "Go Back", value: local!activeStep - 1, saveInto: { local!activeStep, if( local!activeStep = 1, a!save( ri!employee, null ), null ), if( local!activeStep = 1, a!save( ri!address, null ), null ), if( local!activeStep <> 1, a!save( ri!address, rule!EEDM_GetAddressDetailsById( local!startAddressId ).data ), null ), if( local!activeStep <> 1, a!save( ri!employee.addressId, local!startAddressId ), null ), if( local!activeStep = 2, a!save( ri!addressUpdChoice, null ), null ) }
This is from milestone template which uses the same button on most steps and I need to do specific actions depending on which step I'm on.
To me, it seems fine to use IF conditions in this way and it works fine so far.
However, I haven't run into some examples of this here.
Am I using something undocumented or my "works fine" is just coincidence?
Discussion posts and replies are publicly visible
This looks correct, though I think there's a chance you might have issues unless you replace "null" with an empty set {} for the non a!save portion of the if statement. "saveInto" requires a list of saves, and items in the list that return an empty set are safely ignored, but items in the list that return "null" will show up as an entry in the list, which Appian may or may not handle properly right now.
One other thing I spotted is what looks like 2 if()'s that have the same condition. You could just make 1 if() that returns an array of those two outputs on the same "true" condition.
The standard is the empty set {} as the 'false' condition for most if()s I've seen. When the output is strings, it's often "" the empty string.
Thank you, guys! It is a true joy to learn Appian with such a great community! :)