on 05-16-2020 11:01 AM
Hello all,
I am using NodeJs flavor of CAP to create a simple Approval scenario, in which the Manager can approve/reject requests forwarded by his employees.
I am currently banging my head on calling bound actions from Fiori UI (List Report/Object Page), as fiori complains about an "Unknown Operation".
Here is my service definition:
service PlanningService @(
requires: 'authenticated-user',
path: 'planning',
impl: './handlers/planning-service.js'
) {
@(restrict : [ { grant : ['READ', 'WRITE'], to : 'manager', where : 'approver_ID = $user' }, { grant: ['WRITE'], to : 'admin'} ])
entity MyApprovals as projection on db.AccessRequest
actions {
action approveRequest() returns String;
action rejectRequest() returns String;
};
}
I would like to call "approveRequest" or "rejectRequest" from the UI, here is what I did in the annotation file (only UI.LineItem is here, for brevity):
annotate srv.PlanningService.MyApprovals with @(
UI: {
// Other annotation elements removed for brevity
LineItem: [
{$Type: 'UI.DataField', Value: initiator.eMail},
{$Type: 'UI.DataField', Value: accessDate},
{$Type: 'UI.DataField', Value: locationFloor.location.name},
{$Type: 'UI.DataField', Value: locationFloor.name},
{$Type: 'UI.DataField', Value: requestStatus, Criticality: severity},
{
$Type: 'UI.DataFieldForAction',
// Not sure what to put here
Action: 'srv.PlanningService.EntityContainer/MyApprovals_approveRequest',
Label: 'Approve',
Determining: true
},
{
$Type: 'UI.DataFieldForAction',
// Not sure what to put here
Action: 'srv.PlanningService.EntityContainer/MyApprovals_rejectRequest',
Label: 'Reject', Determining: true
}
]
}
)
What I set in the Action tag is only the latest of 1000 tries I did...whatever I set there, Fiori complains.
Testing the action from a REST client works perfectly.
I was not able to find anything on the internet as an example...the only one I found is here: Github. Look at line 96 of the code, and the syntax is the very same I used.
Any hint anyone? It should be something straightforward, but I really cannot sort it out 🙂
Best,
Roberto.
Second Update:
My question doesn't make all sense, or in any case there's a suitable workaround.
A bound action (as the name implies) is bound to its entity, and therefore we can find all the necessary keys in the url.
Working with CAP, is easy as:
const requestId = req.params[0]; // Index based
So, working and question closed 🙂
Best,
Roberto.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.