Skip to Content

Add Custom Logic

This tutorial shows you how to add custom logic to the source code of the SAP Fiori elements application you have already created.
You will learn
  • How to add custom code that changes the value of the urgency property
  • How CAP automatically treats the JavaScript/Java file that you add as a handler
Created by
slavipande
October 12, 2023
Contributors
slavipande

Prerequisites

You have implemented the user interface of your application. Follow the steps in the Add SAP Fiori Elements UIs tutorial that is part of the Develop a Full-Stack CAP Application Following SAP BTP Developer’s Guide tutorial group.

This tutorial follows the guidance provided in the SAP BTP Developer’s Guide.

  • Step 1

    You can create a CAP project in either Node.js or Java. You have to choose one way or the other and follow through. The tabs Node.js and Java provide detailed steps for each alternative way.

  • Step 2

    In this case, the event is triggered after a READ was carried out for the Incidents entity. In your custom handler, you get all the data (in this case, all the incidents) that was read according to the query. You can loop over each of them and, if needed, adjust the data of the response. In this case, you change the value of the urgency property when the title contains the word urgent. The new values for Urgency are then part of the response to the READ request.

    The custom code that you have added changes the title of the incident based on the value in the Urgency field.

Back to top