Reputation: 21
I'm calling a Dynamic Action from a button in order to save my form data via PL/SQL Code using a stored procedure. I prefer using the stored procedure as it gives more control as to how I am saving the data from the form.
I am facing difficulties in getting the normal validation on the column items to warn the user of failed validations to fire before clicking the button that is associated with the Dynamic Action click event. On a normal submit page button the validation works, but I need the flexibility of using a stored procedure and I need the validation. Please can someone advise me on what I might be missing here. Regards from SmashingCode.
Upvotes: 2
Views: 7251
Reputation: 431
Follow the below steps to perform validation before performing DML via Dynamic action:
BEGIN
IF :P1_NAME IS NULL THEN
:P1_ERROR_FLAG := 'Y';
ELSE
:P1_ERROR_FLAG := 'N';
END IF;
END;
// First clear the errors
apex.message.clearErrors();
var errorFlag= $v('P1_ERROR_FLAG');
if(errorFlag == 'Y') {
// Now show new errors
apex.message.showErrors([
{
type: "error",
location: [ "page", "inline" ],
pageItem: "P1_NAME",
message: "Name is required!",
unsafe: false
}
]);
//To stop the further actions from firing
apex.da.cancelEvent.call(this);
}
Upvotes: 3