Skip to Content
Technical Articles
Author's profile photo Ayush Kumar

Creating Extension Project for your Tenant

Authors: Ayush Kumar , Shreya Sinha, and Vipul Khullar 

Previous Blogs in this series:

This is the third blog in the blog series End-to-End extensibility in Multi-Tenant CAP-based Application.

Perquisites:

  1. Have subscribed to the MTA.
  2. Assigned the roles to your user
    1. Create an extension
    2. Delete the extension

Note: The names of the roles will depend on the role names provided to you in the help documentation of that specific application.

  1. Already know about the allow list and blocklist
  2. Aware about the namespace
  3. Sap cds-dk should be greater than 6.3.0 or the latest, locally in the system where we are creating the extension locally.

 

Now let’s look at all the possible extension scenarios possible by extending your application.

To extend the subscribed solution use the following command

cds extend <app-url>/extend -s <subdomain> --force
example :
cds extend https://<AppName>.cfapps.<Region>.hana.ondemand.com/extend -s <subAccountName> --force

Once you have extended the solution you will see a project structure as follows:

  • Db
  • node_modules
  • srv
  • json

Create a .cds file in DB package where all the below scenarios can be created apart from extending the service.

Sample

Extension%20Package%20Structure

Extension Package Structure

Note :

  1. In this blog we are only showing metadata extension.
  2. in your extension. cds create a namespace of your choice adhering to the prefix rule of your project. This namespace will reference the newly created entities when you try to extend your service.
  3. In your service extension, create a namespace that will reference any new service you are trying to create other than extending your existing service.
  4. If you want to see all the below steps individually, then after adding each block of code use cds activate command followed by the passcode.
  5. If you want to see all the functionality in one go after adding all the blocks at once then after adding use cds activate command followed by the passcode.
  6. If  cds activate does not work then try with
    cds activate --to https::/<AppName>.cfapps.<Region>.hana.ondemand.com/extend -s <subAccountName>
    
    

 

Scenario 1: adding a new field in the existing entity

 

Field%20Level%20Extension

Field Level Extension

 

 

Scenario 2: adding a new entity in the extension project

Entity%20Level%20Extension

Entity Level Extension

 

Metadata%20for%20Entity%20Level%20Extension

Metadata for Entity Level Extension

 

Scenario 3: extending the service with the new entity

 

Extending%20the%20current%20Service

Extending the current Service

 

Metadata%20for%20Extended%20Service

Metadata for Extended Service

 

Scenario 4: creating a new service for the extension project

 

Create%20a%20new%20Service

Create a new Service

Metadata%20for%20new%20Service

Metadata for new Service

 

 

 

Scenario 5: Create a composition of an existing

 

Adding%20Entity%20as%20Composition

Adding Entity as Composition

Metadata%20For%20the%20the%20above%20Entity

Metadata for the above Entity

 

 

Note: Associations can also be created in a similar fashion and can be directly consumed on the UI. The only challenge with the association will be to populate the data separately, whereas, in the case of composition, we can insert, and update the data in parent-child format.

Conclusion:

This concludes the end of the blog series on creating in-app field-level, entity-level, and service-level extensions.
Let us know if you have any other thoughts on the topics and if you want us to clarify any further points related to creating such extensions.
Happy reading!

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.