cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal with virtual fields for Fiori draft v4

klaus_kopecz
Participant

I'm using a virtual field in an entity model, like

entity Products : {
  ...
  virtual margin : Decimal(9, 2) 
  ...
}

When building a draft enabled v4 UI on CAP Node.js with Fiori Elements, I can edit Product details on an object page (margin field is not input enabled). When saving a changed dataset, I'm getting the error "SQLITE_ERROR: no such column: margin".

Obviously, the service provider is constructing an sql-statement including the margin-column, which is not on the database (which is correct). When doing http-POSTs on Products, the error does not show up.

Is there anything to do in addition to work with virtual fields in draft mode?

Here are my cds version coordinates:

@sap/cds: 3.33.1 @sap/cds-compiler: 1.24.4 @sap/cds-dk: 1.7.1 @sap/cds-foss: 1.1.0@ sap/cds-messaging: 1.8.2 @sap/cds-reflect: 2.10.2 @sap/cds-rest: 1.6.2 @sap/cds-services: 1.27.1 
Node.js: v12.15.0

Thanks,

heiko_witteborg
Explorer
0 Kudos

Hi Klaus,

sorry for the late answer. Revisiting the behaviour of readonly, virtual and immutable fields in a draft scenario is already on our current todo list, I have added your problem description. We will provide an answer once we have completed this.

Best regards,

Heiko

klaus_kopecz
Participant
0 Kudos

Thanks Heiko!

I would appreciate if you can keep me up-to-date. I would like to demonstrate virtual fields as part of my CAP-book samples. Of course, only if these are working end-to-end.

Klaus

gregorw
Active Contributor
0 Kudos

Hi heiko.witteborg,

you can track that also via this GitHub issue: https://github.com/sapmentors/cap-community/issues/58.

CU
Gregor

klaus_kopecz
Participant
0 Kudos

Hi heiko.witteborg : Any progress in this matter? (https://github.com/sapmentors/cap-community/issues/58)

Thank you!

heiko_witteborg
Explorer
0 Kudos

Hi klaus.kopecz - not done yet, I'm afraid. It's on the to-do list, and we'll definitely let you know when we fixed it.

Best regards, Heiko

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Klaus, Thorsten,

with new version of CDS 4+ this problem should be solved.

BR

Samuel

klaus_kopecz
Participant
0 Kudos

Works like a charm now. Thanks

Answers (1)

Answers (1)

former_member624584
Participant
0 Kudos

Hi Klaus,

I recently had the same issue.
A workaround (until the issue is resolved) is to use the flag @cds.persistence.exists for the property margin.

Cheers,
Thorsten