How to Decompose a Feature in Sitecore Content Hub: A Step-by-Step Guide

Hello Sitecorians! 👋


Welcome to another exciting blog!


We write a lot about building features in Sitecore Content Hub: a new entity definition, a few pages, an external component, some scripts and triggers. But what happens when the business decides a feature is no longer needed? Removing it is harder than building it. A feature in Content Hub is not one thing you delete. It is spread across definitions, relations, pages, components, scripts, triggers, actions, security policies and even delivery platforms, and Content Hub will stop you at the end if you delete them in the wrong order.


Recently, our team retired a Product Kit feature, and I want to share the order that worked for us, the blockers we hit, and the checks we used to make sure nothing was left behind.


So, let's get started! 😊


The Use Case

Remove the Product Kit feature completely from Content Hub (data, UI, automation, security and schema) without breaking the rest of the DAM, and do it the same way in every environment.


The Product Kit feature had grown over time. When we listed everything it touched, it looked like this:


Area

What the feature had

Schema

An entity definition Custom.ProductKit, with relations to Custom.Geography, Custom.Language, Custom.Customer, Custom.Product and M.Asset

Data

All the Product Kit entities created by users

Pages

A main Product Kit page, a creation page and a details page

Components

A React external component, an entity operations component with a Push to downstream system button, a details component and a tabs component

Styling

CSS classes for the m-page-productkitdetail page

Automation

A trigger Custom.ProductKit.GeoValidation, its action, and the scripts GeoValidation and UpdatePushTimestamp

Security

Rules for Product Kit in the user groups for Ecommerce users, Support users and Product Kit users

Delivery

The definition was published to a delivery platform (Experience Edge)

 

Note: I have renamed the client-specific prefixes and groups in this blog (for example Custom. instead of the real prefix). The steps are exactly what we did.

 

Before You Start: The Order Matters


The golden rule is simple: remove the feature from the outside in. Start with what users see and what runs automatically, then the security and the data, and only at the very end the schema itself. Every step removes something the next step depends on.



A few things to settle before you touch anything:
  • Take an inventory per environment. Our QA1 did not match DEV: there, we found only one Product Kit policy, in the Product Kit users group. Check each environment instead of assuming.
  • Decide what goes through a deployment package and what is done by hand. Pages, components and definition changes usually travel in a package. Data, policies and delivery platform publishing are environment specific.
  • Hide, don't delete, pages in the first phase. The production package still contained components on those pages, so we hid the pages now and planned to delete them in the next phase.
  • Export a backup. Export the entities (Excel) and the definition before you delete anything, in case the business asks for the data later.


Step 1: Remove the External Component and Scripts From Code


Start in source control, so the next deployment doesn't bring anything back.

  1. In the React external components project, remove the Product Kit component: its folder, its entry in the build or bundle configuration, and any shared code that only it used.
  2. Build the bundle and make sure nothing else imports the removed files.
  3. In the Content Hub repository (the serialized configuration and scripts), remove the Product Kit scripts, such as GeoValidation and UpdatePushTimestamp, and any trigger or action definitions for the feature.
  4. Raise a pull request with all of this together, so reviewers see the whole removal in one place.

Tip: Search the whole repository for the definition name (ProductKit) before you raise the PR. Hidden references often sit in shared constants, CSS files and other scripts.


Step 2: Clean Up the Pages and Components


Next, remove what users can see. Go to Manage → Pages and open the Product Kit details page.

  1. Remove the external component that loaded the React code you just deleted.
  2. Remove the entity operations component with the Push to downstream system button, so nobody can trigger a push for a feature that is going away.
  3. Remove the details component and the tabs component from the page.
  4. Remove the CSS classes for the feature, for example the ones scoped to m-page-productkitdetail, from your theme or page styling.
  5. Hide the main Product Kit page, the creation page and the details page from navigation.

Hide first, delete later: We first planned to delete the three pages. But the production deployment package in flight still referenced components on them, so deleting now would break the deployment. Hiding them removes them for users today, and we delete the pages in the next phase, after that package is in production.


Step 3: Disable and Delete the Trigger and Actions


Triggers keep firing as long as the definition exists, so switch them off before you touch any data. Otherwise, deleting entities in Step 6 could fire validation or push logic one last time.

  1. Go to Manage → Triggers and open Custom.ProductKit.GeoValidation.
  2. Set it to Inactive and save. Wait a moment and make sure no new jobs for it appear.
  3. Delete the trigger.
  4. Go to Manage → Actions and delete the action the trigger used (Custom.ProductKit.GeoValidation), and the UpdatePushTimestamp action.

Why this order? Content Hub won't let you delete an action that is still used by a trigger. Delete the trigger first, then its action.


Step 4: Disable the Scripts


Go to Manage → Scripts, find GeoValidation and UpdatePushTimestamp, and disable both.

We disabled them instead of deleting them at this stage. A disabled script does nothing, but it is still there if you need to check its logic or roll back. Once the feature is gone from every environment, you can delete them. Since we already removed them from the repository in Step 1, the next deployment won't bring them back.


Step 5: Remove the Feature From Security Policies


User group policies can reference a definition directly, so they need to be cleaned before the definition can go.

  1. Go to Manage → Users → User groups.
  2. Open each group that had access to the feature. For us these were the Ecommerce users group and the Support users group (and, in QA1, the Product Kit users group).
  3. Open Policies and find the rules that target Custom.ProductKit.
  4. Remove those rules and save the group.

Check every environment: In DEV, two groups had Product Kit rules. In QA1, we found only one policy, in the Product Kit users group. Policies drift between environments, so open the groups in each one instead of following a list from another environment.


Step 6: Delete the Feature's Entities

A definition that still has entities can't be deleted, so the data goes next.

  1. Export the entities first (for example to Excel), so you have a copy if the business asks for it later.
  2. Find every entity of the definition. A search page filtered on the definition works, or the API:
GET /api/entities/query?query=Definition.Name=='Custom.ProductKit'&take=100
  1. Delete them. For a few entities, the UI is fine. For many, delete them in batches through the API (DELETE /api/entities/{id}) or a small script, so you don't overload the instance.
  2. Run the query again and confirm it returns 0 results.


Step 7: Remove the Relations From Other Entity Definitions


The feature's definition was linked to five other definitions. Each link is a relation member on the other definition, for example Custom.GeographyToProductKit, where Custom.Geography is the parent and Custom.ProductKit is the child.

Go to Manage → Schema and, for each of these definitions, remove the Product Kit relation member:

Definition

Relation to remove

Custom.Geography

Custom.GeographyToProductKit

Custom.Language

the Language to Product Kit relation

Custom.Customer

the Customer to Product Kit relation

Custom.Product

the Product to Product Kit relation

M.Asset

the Asset to Product Kit relation


When you remove a relation member, Content Hub also removes the other side of the relation from Custom.ProductKit, so you only need to do it once per relation.

Package or UI? We first planned to ship these schema changes in a deployment package. It turned out to be simpler to update the definitions directly in each environment, since the change is a small removal. If your team keeps all schema changes in packages, include them there instead.


Step 8: Unpublish From the Delivery Platform

This is the step that caught us. Our first attempt to delete the definition failed with this message:

Entity definition cannot be deleted because it has been published to delivery platform. It should be unpublished first.



If the definition was ever published to a delivery platform such as Experience Edge, Content Hub keeps a published copy of the schema there, and it won't let you delete the definition while that copy exists.

  1. Go to Manage → Schema and open Custom.ProductKit.
  2. Use the option to unpublish it from the delivery platform.
  3. Wait until the unpublish job finishes (check Manage → Background processes if it takes a while).
  4. If any consumer reads Product Kit data through the delivery platform (a website or a GraphQL query), let that team know before you unpublish, because their queries on this type will stop working.

Step 9: Delete the Entity Definition


Now that the definition has no entities, no relations, no policies and no published copy, Content Hub lets you delete it.

  1. Go to Manage → Schema and open Custom.ProductKit.
  2. Delete the definition.


If the delete still fails, the error message tells you what is left. It is usually one of these:

Message mentions

What is left

Go back to

Entities

Some entities were not deleted

Step 6

A relation or another definition

A relation member is still on another definition

Step 7

A policy or user group

A user group rule still targets the definition

Step 5

The delivery platform

The definition is still published

Step 8


It's Working! 🎉

Before you call the feature gone, check each environment:

  • Manage → Schema has no Custom.ProductKit, and the five other definitions have no Product Kit relation.
  • Manage → Triggers, Actions and Scripts show nothing active for the feature.
  • The user groups have no rules for the feature.
  • The Product Kit pages are hidden from navigation, and the details page no longer shows the push button, details or tabs components.
  • The delivery platform no longer exposes the type.
  • The React bundle and the repository have no references to ProductKit (a quick search proves it).
  • Normal work still runs: upload an asset, edit a geography, language, customer and product record, and run a search, to make sure removing the relations didn't break anything.


Conclusion


Removing a feature from Content Hub is less about deleting and more about order. Start with the code and the pages users see, switch off the automation, clean the security, delete the data, cut the relations, unpublish from the delivery platform, and only then delete the definition. Hide pages instead of deleting them while a deployment still depends on them, and check every environment on its own, because they are never quite the same.


And that's a wrap! 🎉


I hope this helps you in your Content Hub journey! If you have any questions, feel free to drop a comment below. 😊


Stay tuned for more! 👋

Post a Comment (0)
Previous Post Next Post