I have an interface that opens for a single record passed in via a rule input from a REST integration GET call. The interface opens as read-only be default. There is a button at the bottom labeled "Edit". When the user clicks this button, interface becomes editable. When the interface is editable, there is a button labeled "Cancel" at the bottom. When the user clicks the "Cancel" button, I need to discard any changes the user made, and revert back to the original copy of the record.
I have attempted to do this by calling the integration which is the GET by ID in the saveInto of the Cancel button. The value is successfully fetched, and I can view it when I put the result into a paragraph field, but when I assign this result back to the rule input, the fields of the interface are not updated and the user changes are not reverted.
Is there an easier way to discard the user changes and go back to the original record?
NOTE: The goal of the Cancel button is NOT to close the interface, but to cancel "edit mode".
Discussion posts and replies are publicly visible
instead of calling integration again on cancel button, we can store the initial value(rule input) in a local variable, and save the initial values back in rule input on click of 'cancel' button.here is an example ->
a!localVariables( local!initialData: a!refreshVariable( value: ri!apiData, refreshOnReferencedVarChange: false ), local!isEditable:false, { a!textField( label: "Text", labelPosition: "ABOVE", saveInto: {ri!apiData}, value: ri!apiData, readOnly: not(local!isEditable), refreshAfter: "UNFOCUS", validations: {} ), a!buttonArrayLayout( buttons: { a!buttonWidget( label: "edit", style: "OUTLINE", saveInto: a!save(local!isEditable,true), showWhen: not(local!isEditable) ), a!buttonWidget( label: "caancel", style: "OUTLINE", saveInto: {a!save(local!isEditable,false),a!save(ri!apiData,local!initialData)}, showWhen: local!isEditable ) }, align: "START", marginBelow: "NONE" ) })
Additionally, I was able to use this methodology in combination with the "exact()" function to disable the Save button if there are no changes.
that will save an another integration / database call