Under the form, I have a save button that will be disabled after the form submission. The button should be enabled if any changes are made to the data or a comment is added.Any help will be appreciated.
Discussion posts and replies are publicly visible
I recommend to not implement one huge form covering all use cases. This becomes complex and hard to maintain.
But, to answer your question, add a local variable "isModified" and default it to false. Then add a a!save() to all fields to update isModified to true(). Then use that status to add some logic to the submit button.
Now, check my first sentence ...
For what it's worth, this could have just been a new comment in your existing thread on the same subject. The problem with arbitrarily staring brand new threads is that people seeing it for the first time won't be able to review the past comments and any context they may provide.
do u have any example to quote?
A simplified example:
a!textField( label: "my data", value: ri!textField1Value, saveInto: { ri!textField1Value, a!save( local!isModified, true() ) } )
if there are nested interfaces, where the above example for data comparison cant be used?
for any child interfaces where data could also be modified, and which would thus need to trip the "isModified" flag, simply pass in the "isModified" local variable into a rule input in the child(ren), and save into it from any relevant field(s) there.
a!localVariables( local!data: { ri!datasubset, ri!transValue, ri!orgValue, ri!ageValue }, local!originalData:local!data, local!modified: not( exact( tostring(local!data), tostring(local!originalData) ) ), a!formLayout( buttons: a!buttonLayout( primaryButtons: if( ri!isEditable, { if( ri!canSubmit, a!buttonWidget( label: cons!BUTTON_VAL_SUBMIT, style: "PRIMARY", submit: true(), validate: true(), value: cons!BUTTON_VAL_SUBMIT, saveInto: ri!buttonAction, disabled: if( and(rule!APN_hasValue ( ri!SubmissionDate),local!originalData<>local!modified), false(), true(), ) ), {} ), a!buttonWidgetSubmit( label: cons!BUTTON_VAL_SAVE, style: if( ri!canSubmit, "NORMAL", "PRIMARY" ), submit: true(), validate: true(), value: cons!BUTTON_VAL_SAVE, saveInto: ri!buttonAction, disabled: if( and(rule!APN_hasValue ( ri!SubmissionDate),local!originalData<>local!modified), false(), true(), ) ) }, {} ) ) ) )
I tried this code for the interface with multiple child interfaces. buts it's not working.even if data is changed , the buttons are not getting enabled. Any suggestions?
This would work except the way you've declared local!originalData, is causing it to automatically update any time any change is made to local!data.
Remember that a!localVariables() variables have a default behavior which assumes "refresh on referenced var change" is TRUE. That means, as you have it written, if you save anything into ri!orgValue (for instance), it automatically refreshes local!data, which by update chaining, updates local!originalData (which you don't want).
Luckily the fix is very simple.
local!originalData: a!refreshVariable( value: local!data, refreshOnReferencedVarChange: false() )
With the above change in place, your "local!modified" variable should now properly hold its existing value in spite of updates made to the referenced variable.
I tried this way and it seems it's not performing data comparison. Is there any other possible way, it can perform a logical comparison and gets enables button with the changes
Where and how are you saving the updates to the "local!data" variable (and/or its refernced variables)?