How to have human readable identifiers in Sitecore Content Hub?

Do I need human-readable identifiers?

Before I answer the question – how to have a human-readable identifier in Sitecore Content Hub – I will explain why we need identifiers different from ao84XjNX-Eabf_uvVPTfZA.

Usage in a code

For example, when you write a code using API, and you would like to get an entity with a specific identifier, it will be much easier to remember M.Script.CMP.Usage.Delete than ao84XjNX-Eabf_uvVPTfZA. 

var entity = await client.Entities.GetAsync("M.Script.CMP.Usage.Delete");

A human-readable identifier is also better when you back later to the code, and you will know that code is processing a script entity.

Usage in data import

If you need to use identifiers during import via Excel is better to give a business user a choice to enter human-readable identifiers then ‘magic numbers’

How to create an entity with a human-readable identifier.

In the case of scripts, we have a user interface with a button +Script, but this way, we will get a unique random identifier, which is not our goal.

Create a script with user interface

Suppose you want to add an entity and be able to modify all properties without any limitations. In that case, you should go to Admin->Entities and then choose an entity definition, to get a list of all entities.
On the video is shown how to add, for example, an asset with a human-readable identifier.

Edit entity in a superuser mode

In this way, you can add entities for definitions listed on Admin->Entities page. However, all system entities are hidden, and you need to know the entity definition ID to list all entities. So, let’s back to our script entity. To check the entity definition id, you need to use API.

https://contenthub-hostname/api/entitydefinitions/M.Script

As you can see, the ID for M.Script definition is 100.

So now open any entity and replace id with 100. Now you can add a M.Script entity in a superuser mode and specify an human-readable identifier.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.