Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

5. Feature Toggled Extensions

Daniel edited this page Nov 15, 2022 · 6 revisions

In the previous excercise we learned how 3rd party vendors could provide pre-built verticalization packages as extensions to SaaS applications which they share for reuse by multiple SaaS customers.

Now, in this chapter we slip back into the shoes of the SaaS Provider to add such pre-built extensions as part of the base application itself, which can be feature-toggled per tenant.

In our exercise we, as the SaaS provider, want to provide the very same extension we built before as a toggled feature, offered to customers in the solar panel industry.

Create the Extension

Toggled features are part of of the base application, with their content — mainly CDS models — stored in a specific folder of a CAP-based projects. That folders is ./fts/<feature> by default. So let's do it...

  1. Switch to the browser tab of the incidents project

  2. Create a new folder for your feature: ./fts/solar by clicking on the New Folder icon to the top of the Explorer pane then enter fts/solar in the inline input field, followed by Return.

    image-20221114140722771

  3. Add your extension content in there, essentially the very same way as we did in the exercises before. So instead of doing that again, let's just copy the files we created by running this command in the Terminal:

    cp ../x-t1/app/* fts/solar
  4. Fix the errors on line 1 in the copied ./fts/extension.cds to import the base model from local ./db/schema.cds file as follows:

    using { sap.capire.incmgt.Incidents } from '../../db/schema';
  5. Fix the errors on line 5 in the copied ./fts/fiori.cds to import the fiori model from local ./app/fiori.cds file as follows:

    using { IncidentsService } from '../../app/fiori';
    using from './extensions'; 

Toggling Features

In production, special feature toggle services would be used to enable or disable features for individual tenants dynamically. In our exercise using mocked-auth we simulate this by statically adding a corresponsing feature assignment to the configuration for tenant t3...

  1. Open the package.json file, and add the following setting to the cds configuration:

    {
      "cds": {
        "requires": {
          "auth": { ...,
            "tenants": {
              "t2": { "features": [] },
              "t3": { "features": ["solar"] }
            }
          ...
  2. Restart the app server (→ as in exercise 2)

  3. Switch to the Launpad for AD264 browser tab

  4. Click on the [ Erin (t3) ] button → opens a new tab with the Incidents list view in which we see the Components column, this time delivered through the toggled feature for tenant t3

  5. Go on testing the UI as in the exercises before.

Add Value Lists

... optional ...

Summary

You've now learned how to provide extension content to selected tenants of your application.

Clone this wiki locally