Adding System Field Validation

Objective

After completing this lesson, you will be able to implement system field validation on button press to enforce required input before creating a document.

How to Add a Field Validation for a System Button

Two people on opposite sides of the SAP logo

In a previous lesson, Jayson Butler, the sales manager at OEC Computers, asked Emily to make changes so that whenever a sales employee creates a sales quotation, they must enter the customer reference number.

Emily has already extended the Sales Quotation Detail view in the Web client and now she needs to add a validation on the Customer Reference Number system field. This way, the sales employee can only create a sales quotation if this field contains a value.

The Sales Quotation Detail view in the Web client highlighting the Add & View button at the bottom of the page.
A pop-up window on over the Sales Quotation Detail view in the Web client showing that the validation failed because they didn’t provide a customer reference number

This scenario uses the same source code sample that we reviewed in the previous lesson. If you don’t already have the source code sample opened, you can open it here: Sales Assist App Sample.

Summary

  • System field validation ensures, for example, that a sales quotation cannot be created without a customer reference number.
  • The button’s GUID is defined in the layout JSON file to capture the Add button press event.
  • Validation logic in JavaScript can check if the customer reference number field is empty and displays a message if needed.
  • The default system behavior is prevented if validation fails, requiring user input before proceeding.