on 02-02-2022 9:31 PM
Hello SAP CAP Experts,
I have created a simply cds table with managed and I want to get the created by and modified by fields, As SAP has given this inbuilt functionality using "manage", when i post the records into my table via an entity the createdby and modifiedby fields fills with value "anonymous".
My schma.cds file have this code
using { Currency, managed, cuid, sap} from '@sap/cds/common';key ID : Integer; STATUS : String;
PROMOTION_TYPE : String;
key key WEEK : Date
}In my service.cds i have it like this
entity Promotions as projection on PromService.Promotions;
What else I need to do to get the correct user in createdby and modifiedby fields?
To get real users stored in the created by field you have you add Authentication.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need below annotation either on service level or entity level to have your user authenticated.
@requires: 'authenticated-user'
example:
service CustomerService @(requires: 'authenticated-user'){
...
}
service CustomerService {
entity Orders @(restrict: [
{ grant: ['READ','WRITE'], to: 'authenticated-user' },
]){/*...*/}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.