Hi All,
I have an interface where I use the function a!writeToDataStoreEntity when I click on the submit button.
In the function a!writeToDataStoreEntity, I declare a variable where save the value for the onSuccess or onError . If this variable is onError, I don't want to submit the interface and advice the user about the error. Is there a way to make this?
This is an example of my case
a!formLayout( firstColumnContents: {allMyfields }, buttons: { a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: "Start", style: "PRIMARY", value: "start", saveInto: { a!writeToDataStoreEntity( dataStoreEntity: cons!myDataStore, valueToStore: local!myCDT, onSuccess: { a!save( local!resultWriteToDB, "Data Inserted" ), a!save( ri!newBBSID, fv!storedValues.ID ) }, onError: { a!save( local!resultWriteToDB, "Data not Inserted" ) } ) }, validate:true, validationGroup: "checkSave" ) } ),
}, validationGroup: "checkSave", validations: { a!validationMessage( message:if(local!resultWriteToDB="Data Inserted","saved",""), validateAfter:"SUBMIT" ) } )
Thanks in advance.
Discussion posts and replies are publicly visible
Something that I've tried that seems to work is having a local variable such as local!error that defaults to false. In onSuccess use a!save(local!error,false) and in onError use a!save(local!error,true). Then in your a!buttonWidget(), have submit:not(local!error). This way if the evaluation results in an error, then the form won't submit.
local!error
onSuccess
a!save(local!error,false)
onError
a!save(local!error,true)
a!buttonWidget()
submit:not(local!error)
jurim409 - I think you'll need to do the a!WTDS call earlier in your form if you want the submit button to not submit in the case of an error.
- FYI, using the with() function would cause a failure in this case, as they are trying to write a value directly into the local!error variable. You'll find that if you try to manually set a value into a with() variable, in any situation, the form will give you an error.