Skip to content

5. Feature Toggled Extensions

Arley Triana Morin edited this page Jun 27, 2023 · 11 revisions

In the previous exercise, we learned how 3rd party vendors could provide pre-built verticalization packages as extensions to SaaS applications that 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, as the SaaS provider, we want to provide the 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 the base application, with their content — mainly CDS models — stored in a specific folder of CAP-based projects. That folder 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 at 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 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 dynamically turn features for individual tenants on or off. In our exercise using mocked-auth, we simulate this by statically adding a corresponding feature assignment to the configuration for tenant t3...

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

    {
      "cds": {
        "requires": {
          "auth": { ...,
            "tenants": {
              "t2": { "features": [] },
              "t3": { "features": ["solar"] }
            }
          ...
  2. Re-subscribe t3 to activate the toggled extension → enter this in the Terminal:

    cds subscribe t3 --to http://localhost:4004 -u erin
  3. Restart the app server (→ as in exercise 2)

  4. Switch to the LaunchPad for AD264 browser tab

  5. 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

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

Add Value Lists

Summary

So in this final exercise, we took the same extension we developed before and turned it into a toggled feature of the base application.

CAP Spotlights:

  • Feature Toggles — allows SaaS providers to have pre-built extensions bundled with their SaaS applications to provide industry-specific verticalizations and other extensions out-ouf-the-box, and toggle them easily per customer tenant, user or even single requests.

Go on to the final summary section of this hands-on walkthrough.

Clone this wiki locally