cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Fiori Elements Action: Navigation Not Triggering After Returning New Instance

KirubakaranK
Newcomer
0 Kudos
104

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:

  • The action returns a single entity with a new ID.
  • Object page target is defined for target entity.
  • navigateToInstance: true is set under actions.
  • Backend response includes all key fields and metadata context.
// <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

Accepted Solutions (0)

Answers (0)