From 25472510db7aee98a21f9121098f4460ddc105a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20G=C3=B6rler?= Date: Wed, 5 Aug 2026 19:42:35 +0200 Subject: [PATCH 1/3] adding user description --- java/fiori-drafts.md | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/java/fiori-drafts.md b/java/fiori-drafts.md index 5c4203c303..af0dcba95b 100644 --- a/java/fiori-drafts.md +++ b/java/fiori-drafts.md @@ -234,6 +234,51 @@ public void createDraft(CreateDraftContext context) { } ``` +## Showing a Custom User Description { #draft-user-description} + +By default, the SAP Fiori draft UI displays the technical user ID in fields such as *Locked by*. To show a human-readable name instead, enable the `draftUserDescription` CDS compiler option and populate the generated `InProcessByUserDescription` field via a custom handler. + +**1. Enable the compiler option** in your `.cdsrc.json`: + +```json +{ + "cdsc": { + "draftUserDescription": true + } +} +``` + +This adds `InProcessByUserDescription`, `CreatedByUserDescription`, and `LastChangedByUserDescription` to the `DraftAdministrativeData` entity. + +**2. Register a `@Before` handler** on `DRAFT_CREATE` across all draft services to populate the field: + +```java +@Component +@ServiceName(value = "*", type = DraftService.class) +public class UserDescriptionHandler implements EventHandler { + + @Autowired private UserInfo userInfo; + + @Before + protected void addDraftFields(DraftCreateEventContext context, List entries) { + CdsDataProcessor.Filter filter = + (path, element, type) -> "InProcessByUserDescription".equals(element.getName()); + CdsDataProcessor.Generator generator = (path, element, isNull) -> description(); + CdsDataProcessor.create().addGenerator(filter, generator).process(entries, context.getTarget()); + } + + private String description() { + return userInfo.getAdditionalAttribute("given_name") + + " " + + userInfo.getAdditionalAttribute("family_name"); + } +} +``` + +::: tip +The attribute names `given_name` and `family_name` correspond to JWT token claims provided by your IdP. Adjust them to match the claims configured in your environment. +::: + ## Consuming Draft Services { #draftservices} If an [Application Service](cqn-services/application-services#application-services) is created based on a service definition, that contains a draft-enabled entity, it also implements the [DraftService](https://www.javadoc.io/doc/com.sap.cds/cds-services-api/latest/com/sap/cds/services/draft/DraftService.html) interface. From 65b7d1383744cbe5d9426c00e5423858fe2d5419 Mon Sep 17 00:00:00 2001 From: Marc Becker Date: Mon, 31 Aug 2026 11:40:04 +0200 Subject: [PATCH 2/3] Apply suggestion from @beckermarc --- java/fiori-drafts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/fiori-drafts.md b/java/fiori-drafts.md index af0dcba95b..53bef61515 100644 --- a/java/fiori-drafts.md +++ b/java/fiori-drafts.md @@ -236,7 +236,7 @@ public void createDraft(CreateDraftContext context) { ## Showing a Custom User Description { #draft-user-description} -By default, the SAP Fiori draft UI displays the technical user ID in fields such as *Locked by*. To show a human-readable name instead, enable the `draftUserDescription` CDS compiler option and populate the generated `InProcessByUserDescription` field via a custom handler. +By default, the SAP Fiori draft UI displays the unique user name in fields such as *Locked by*. To show a human-readable name instead, enable the `draftUserDescription` CDS compiler option and populate the generated `InProcessByUserDescription` field via a custom handler. **1. Enable the compiler option** in your `.cdsrc.json`: From bc22ba8c70fe5369e2af5da015048760c029b0c6 Mon Sep 17 00:00:00 2001 From: Marc Becker Date: Tue, 1 Sep 2026 08:26:51 +0200 Subject: [PATCH 3/3] Apply suggestion from @smahati Co-authored-by: Mahati Shankar <93712176+smahati@users.noreply.github.com> --- java/fiori-drafts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/fiori-drafts.md b/java/fiori-drafts.md index 53bef61515..a4c18e41d4 100644 --- a/java/fiori-drafts.md +++ b/java/fiori-drafts.md @@ -248,7 +248,7 @@ By default, the SAP Fiori draft UI displays the unique user name in fields such } ``` -This adds `InProcessByUserDescription`, `CreatedByUserDescription`, and `LastChangedByUserDescription` to the `DraftAdministrativeData` entity. +The compiler now adds `InProcessByUserDescription`, `CreatedByUserDescription`, and `LastChangedByUserDescription` to the `DraftAdministrativeData` entity. **2. Register a `@Before` handler** on `DRAFT_CREATE` across all draft services to populate the field: