submit form based on integration results called on submit button click

Hi,

I have a requirement to call an integration on submit button click. Based on the response from integration if error occurred i need to hold the form from being submitted or if its success i need to submit the form but should inform the user about the success through the success message. Any suggestions or design guidance would help.

local!errorMessage,

a!sectionLayout(
label: "Segment Action",
labelSize: "SMALL",
labelColor: cons!CORE_BRANDING_LABEL_COLOR,
contents: {

a!columnsLayout(...),

a!columnsLayout(...),

a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Save",
submit: true,
saveInto: {

rule!PM_AutoUpdatePRNSegment(....
onSuccess: {
a!save(
local!successMessage,
fv!result.body.message
)
},
onError: {
a!save(
local!errorMessage,
fv!result.body.message
)
}

style: "PRIMARY",
disabled: local!disablerule,
showWhen: local!initialAction,
validate: true(),
validationGroup: ri!index
)
},
align: "END"
)
},
validations: if(isnull(local!errorMessage),{},local!errorMessage),
isCollapsible: true,
divider: "BELOW"
)

  Discussion posts and replies are publicly visible