Skip to content

Move draft user description docu from Java to Fiori guide - #2969

Open
rjayasinghe wants to merge 4 commits into
mainfrom
2972_move_draft_description_docu
Open

rjayasinghe wants to merge 4 commits into
mainfrom
2972_move_draft_description_docu

Conversation

@rjayasinghe

Copy link
Copy Markdown
Contributor

Summary

  • Moves the "Showing a Custom User Description" section from java/fiori-drafts.md into the shared guides/uis/fiori.md under the Fiori Draft Support section
  • Content is marked Java-only via ::: warning Only Java (consistent with how other Java-only features are marked in that file)
  • The Java page retains the section heading and anchor (#draft-user-description) with a .learn-more link pointing to the new location

Closes https://github.wdf.sap.corp/cds-java/home/issues/2972

Moves the "Showing a Custom User Description" section from the Java-specific
fiori-drafts page into the shared guides/uis/fiori page, marked as Java-only
via a warning callout. The Java page now has a learn-more link pointing to
the new location.

Closes https://github.wdf.sap.corp/cds-java/home/issues/2972
@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Control Panel

Hi, I'm an AI-powered Review Bot that helps you with summarizing and reviewing pull requests.
To interact with me, just use the following actions:

  • 📝 Summarize PR
  • 🔍 Review
  • 🗑️ Delete all bot comments and reviews

Comment thread guides/uis/fiori.md Resolved
Comment thread guides/uis/fiori.md
Comment on lines +507 to +528
```java
@Component
@ServiceName(value = "*", type = DraftService.class)
public class UserDescriptionHandler implements EventHandler {

@Autowired private UserInfo userInfo;

@Before
protected void addDraftFields(DraftCreateEventContext context, List<CdsData> 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");
}
}
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler is specific for CAP Java. I guess it should be possible to have a corresponding handler for CAP Node.js

-> https://github.tools.sap/cap/cdsnode/issues/708#issuecomment-677683

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.tools.sap/cap/cdsnode/issues/708#issuecomment-677683

This handler is specific for Order. A corresponding handler in AP Java would be simpler, of course:

    @Before
    protected void addDraftFields(DraftCreateEventContext context, List<Order> orders) {
        orders.forEach(o -> o.setInProcessByUserDescription(description()));
    }

    private String description() {
        return userInfo.getAdditionalAttribute("given_name")
            + " "
            + userInfo.getAdditionalAttribute("family_name");
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if this looks good now :)

@rjayasinghe
rjayasinghe requested a review from agoerler November 6, 2026 10:25
Comment thread guides/uis/fiori.md

**2. Register a handler** on draft events across all draft services to populate the field:

This is how the handler could look for CAP Java:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is how the handler could look for CAP Java:
This is how the handler could look for CAP Java that fills in the user decription for the draft-enabled entity `Orders`:

Comment thread guides/uis/fiori.md Outdated
@Autowired private UserInfo userInfo;

@Before
protected void addDraftFields(DraftCreateEventContext context, List<Order> orders) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected void addDraftFields(DraftCreateEventContext context, List<Order> orders) {
protected void addDraftFields(DraftCreateEventContext context, List<Orders> orders) {

Comment thread guides/uis/fiori.md Outdated

```javascript
srv.on('PATCH', Order, req => {
req.data.LastChangedByUserDescription = req.user.attr.firstName + ' ' + req.user.attr.lastName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three striking differences compared to the Java handler:

  • the Java handler handles multiple orders whereas this handler handles a single order
  • the Java handler changes InProcessByUserDescription whereas this handler changes LastChangedByUserDescription
  • the Java handlers uses the claims given_name and family_namewheras this handler uses firstName and lastName

I think this needs to be clarified.

@agoerler agoerler Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This proposal by @schiwekM for CAP Node.js used givenName and familyName.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Sadly we can't have the tip at line 535 for both runtimes..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agoerler harmonized javascript and java version.

@rjayasinghe
rjayasinghe requested a review from agoerler November 6, 2026 14:26

@agoerler agoerler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @sjvans -please also have a look.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants