SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →Reference

cap-defaultvalue-function

Common.DefaultValuesFunction pointed at a service function: getDefaultValues() selects the highest existing ID and returns that plus one, leaving the second key element to the user.

Books has a two-part key, ID and shop, with ID annotated @readonly so nobody types it. The entity is @odata.draft.enabled, the function is declared on the service beside it and annotated as the entity's Common.DefaultValuesFunction, and its handler orders Books by ID descending, takes the first row and returns { ID: ID + 1 }, so shop stays empty. An app under app/bookshop, listed in sapux, carries the generated field group and UI.LineItem annotations. One commit, from December 2024, and the README is the CAP scaffold's own getting-started text, so the annotation and that handler are the whole of it.

Facts

Last pushLicenceUNLICENSED

Where it sits

Lives in
Demonstrates
Fiori annotationsCAPFiori annotationscapabilityDescribing a service so a Fiori client can render it without hand-written UI code — titles, value helps, hierarchies and visibility expressed as model annotations rather than screen logic.Draft handlingCAPDraft handlingcapabilityLetting a user edit a record over several requests before it becomes real — saving unfinished changes, locking, and activating a completed draft.
Flavors
Node.jsfrom its runtime
Requires
@sap/cds^8@sap/cdsartifactThe peer range, as published.

Who is behind it

Mio YasutakeMio YasutakePersonMaintains this
In the atlas: maintains 47, contributes to 47, wrote 10
@miyasuta
maintainer

What it declares

Every artifact

Type
Sample
Origin
Independently maintained
Use as
A reference
Runtime
Node.js

As a sample

Declared for
^8
Form
does not say

Connections2

cap-defaultvalue-function connectionscap-defaultvalue-functionPROVIDES→ demonstrates2demonstrates authoredDraft handlingdemonstrates authoredFiori annotations

README

quoted from miyasuta/cap-defaultvalue-function, read
miyasuta/cap-defaultvalue-function/README.mdOn GitHub

Getting Started

Welcome to your new project.

It contains these folders and files, following our recommended project layout:

File or FolderPurpose
app/content for UI frontends goes here
db/your domain models and data go here
srv/your service models and code go here
package.jsonproject metadata and configuration
readme.mdthis getting started guide
excerpt, UNLICENSED, read the rest, on GitHub

Details

Sources3
GitHub APIdiscovered here, miyasutachecked
github.com/miyasuta/cap-defaultvalue-functiontree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
runtimesnode
declared for^8
discovered viaGitHub API · miyasuta
first seen in the atlas
ecosystem and domaincap, ui-and-frontend-bridge
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:miyasuta-cap-defaultvalue-function
JSON
/artifacts/miyasuta-cap-defaultvalue-function.json
MCP
Connecting an agent