Custom validation logic not firing on Fiori opportunity form submission

Custom validation for opportunity fields does not execute when users submit the Fiori opportunity creation form. We’ve implemented client-side validation to enforce data quality rules (e.g., expected close date must be within fiscal year, deal size must match product category ranges), but the form submits without running our validation logic.

Validation handler in controller:

onBeforeSubmit: function(oEvent) {
  var isValid = this.validateOpportunityData();
  if (!isValid) {
    oEvent.preventDefault();
  }
}

The form submission goes through even when validation should fail, creating opportunities with invalid data. I’ve attached the handler to what I thought was the submit event, but it’s never being called. The UI5 event handling documentation shows various form events, but I’m not sure which one is the correct interception point for Fiori opportunity forms. This is creating significant data quality risk as opportunities are being created without proper validation. Has anyone successfully implemented custom validation logic in the standard Fiori opportunity management app?

I checked and yes, the opportunity app is using draft mode. How do I access the draft controller’s beforeSave event from my custom controller extension? Is there a specific extension point I need to declare in the manifest?

For Fiori Elements applications, custom validation needs to be implemented through extension points rather than direct event handlers. You should be using the onBeforeSave extension method in your controller extension. Also verify that you’re extending the correct controller - opportunity forms might have multiple controllers depending on the create/edit scenario.

You need to extend the ObjectPage controller and override the onBeforeSave method. In your controller extension file, implement the extension point and return a Promise that resolves only if validation passes. The draft controller will wait for your Promise before proceeding with the save operation. Make sure to register the extension in your manifest.json under sap.ui5/extends/extensions.