Skip to Content
0
Aug 02, 2023 at 11:44 AM

Side Effect: Can the content of an Calculated / Virtual Field be updated in draft

110 Views

Hello SAP CAP and Fiori Elements Experts,

I try to follow the Side Effect Annotations: Examples --> Additional Features in SAP Fiori Elements for OData V4 in my sample project. But the annotation:

 @Common.SideEffects #effect: {
    SourceProperties: [taxPercentage],
    TargetProperties: [
      ComputedTotalWithTax,
      ComputedTax
    ]
  }

Doesn't update the content of the Computed fields when I change the taxPercentage. I’ve tried also with a virtual field where I’ve added the calculation in the handler:

  this.after("each", Orders, (order) => {
    order.VirtualTotalWithTax =
      order.total + (order.total * order.taxPercentage) / 100;
  });

But this resulted in an endless loop when switching to the edit mode. There the Fiori Elements App requested endlessly the field VirtualTotalWithTax.

Does anyone had success creating an example where a calculated field is updated while being in draft?

Best Regards
Gregor