Check the write to Data Store after submit a interface

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

Parents
  • As others have mentioned, once the saveInto occurs for a submitting button, you don't really have a way of checking the saved values before submitting the form. I've run into this problem in the past, and my solution was to have a gateway immediately after the input task in the process model that checked for the error, and if there was one, it immediately chained back into the same task and notified the user of the error, so it has the exact same appearance as if it had validated before submitting. This won't work for every use case since it does recreate the task which could be problematic in some applications that maybe depend on the age of a task, but it could be a viable solution.
Reply
  • As others have mentioned, once the saveInto occurs for a submitting button, you don't really have a way of checking the saved values before submitting the form. I've run into this problem in the past, and my solution was to have a gateway immediately after the input task in the process model that checked for the error, and if there was one, it immediately chained back into the same task and notified the user of the error, so it has the exact same appearance as if it had validated before submitting. This won't work for every use case since it does recreate the task which could be problematic in some applications that maybe depend on the age of a task, but it could be a viable solution.
Children
No Data