a month ago
Hi SAP Community,
I'm working with SAP Fiori Elements (V4) and CAP, and I have an action defined using @ui.DataFieldForAction that creates a new record with updated effective dates. The backend correctly returns a new instance (confirmed via HTTP 200 OK with full entity data), and I've set navigateToInstance: true in the manifest.json.
Despite this, the navigation to the object page of the newly created instance is not happening.
Here’s what I’ve already checked:
// <service.js> - when action triggers, this below is executed
const { ID } = req.params[0];
const { targetentity } = cds.entities('MyService')
if (ID) {
const record = await SELECT.one.from(targetentity).where({ ID });
const newID = uuid();
console.log("New ID", newID);
if (record) {
// Logic to change the effective date
record.effective_start_date = req.data.eStartDate;
record.effective_end_date = req.data.eEndDate;
record.ID = newID;
await INSERT.into(targetentity).entries(record);
// ✅ Return the new instance explicitly
const newRecord = await SELECT.one.from(IARuleForDerivations).where({ ID: newID });
req.reply(newRecord);
/* I try these things also
* return newRecord
*/
} else {
throw new Error("Record not found.");
}
} else {
throw new Error("ID is undefined.");
}
// <service.cds> Entity Projection with actions
@odata.draft.enabled
entity targetentity as projection on db.targetentity
actions {
action changeEffectiveDateToNewRecord(
@UI.ParameterDefaultValue: in.effective_start_date
eStartDate : db.targetentity: effective_start_date,
@UI.ParameterDefaultValue: in.effective_end_date
eEndDate : db.targetentity: effective_end_date)
returns targetentity;
};
Is there anything else I need to configure in the manifest.json or annotations to ensure navigation is triggered correctly?
Thanks in advance,
Kirubakaran K
Request clarification before answering.
User | Count |
---|---|
31 | |
15 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.