cancel
Showing results for 
Search instead for 
Did you mean: 

Sample application for feature bypass_draft

Dinu
Active Participant
0 Kudos

Is there a sample application demonstrating the feature bypass_draft?

The animation in the release note appeared to be using sap_sample/cap_sflight. I tried to enable the feature in the main branch. But got errors (in travel-service.js:146) while doing the same steps as in the demo animation.

[odata] - > PATCH Travel(TravelUUID='75757221A8E4645C17002DF03754AB66',IsActiveEntity=true)
[cds] - TypeError: to_Booking is not iterable
    at TravelService.<anonymous> (\cap-sflight\srv\travel-service.js:146:29)

Fixing this as below did not help to get further to reproduce the demonstration.

if (to_Booking) 
for (const booking of to_Booking) {..

This threw validation errors. I guess the application logic in the sample is not adapted for this feature.

Where can I get hold of the sample application used in the demonstration?

I tried to enable the feature in the sample application generated by cds add sample. This caused the server to crash when editing a record using the Edit button on the list to change the price of one Book.

[odata] - > PATCH Books(ID=201,IsActiveEntity=true)
[cds] - TypeError: Cannot read properties of undefined (reading '@Common.DraftRoot.ActivationAction')<br>    at cds.ApplicationService.handle (\capv7-bypass-draft\node_modules\@sap\cds\libx\_runtime\fiori\lean-draft.js:392:46)

Patching the code that caused this error helped to edit price. But changing stock throws another error:

[cds] - DeserializationError: Error while deserializing payload
    at BufferedWriter.<anonymous> (\capv7-bypass-draft\node_modules\@sap\cds\libx\_runtime\cds-services\adapter\odata-v4\okra\odata-server\deserializer\DeserializerFactory.js:233:18

So I am also wondering if this feature is released for productive use at all. Would you have had better experience using this feature than I had? The release note does not mention that this feature is released as preview?

PS: Using cds version 7.5.2

Accepted Solutions (1)

Accepted Solutions (1)

Marian_Zeis
Active Contributor
0 Kudos

As gregorw mentioned, it does not work yet with CAP, but you can activate the Mass Edit following this documentation. I havent tried it out, but it should work:

https://sapui5.hana.ondemand.com/sdk/#/topic/7cc4f04364c540c397130ff92f84c3ca.html

Dinu
Active Participant
0 Kudos

Thanks Marian.

I enabled the Edit feature in Fiori Elements and got the Edit Button, but I faced the issues mentioned in the question later on. That is why I am asking, if anyone has a got a demo working. So far, I have only seen the animation in the release notes, not a working setup.

Gregor wrote that you got a response from SAP that the issue you reported will be fixed with CDS 7.6. Did they say if the whole feature is broken till then or is it your special case that is broken?

Marian_Zeis
Active Contributor
0 Kudos

It did not work at all, so best to wait for the fix and try again.

Marian_Zeis
Active Contributor
0 Kudos
@Dinu Was fixed with version 7.5.3 in @sap/cds

Answers (3)

Answers (3)

Dinu
Active Participant
0 Kudos

Here are the changes I made to  sap_sample/cap_sflight  to reproduce the animation  the release notes for feature bypass_draft. You need to use cds version 7.5.3 or better. 

diff --git a/app/travel_processor/webapp/manifest.json b/app/travel_processor/webapp/manifest.json
index 79941ba..e84099b 100644
--- a/app/travel_processor/webapp/manifest.json
+++ b/app/travel_processor/webapp/manifest.json
@@ -124,6 +124,11 @@
"settings": {
"entitySet": "Travel",
"controlConfiguration": {
+ "@com.sap.vocabularies.UI.v1.LineItem": {
+ "tableSettings": {
+ "enableMassEdit": true
+ }
+ },
"@com.sap.vocabularies.UI.v1.SelectionFields": {
"useSemanticDateRange": true
}
diff --git a/package.json b/package.json
index c24e1f7..d9bcd02 100644
--- a/package.json
+++ b/package.json
@@ -35,6 +35,9 @@
"qunit": "^2.9.3"
},
"cds": {
+ "fiori" : {
+ "bypass_draft": true
+ },
"requires": {
"db": {
"kind": "sql"
diff --git a/srv/travel-service.js b/srv/travel-service.js
index 4741b67..43bf64e 100644
--- a/srv/travel-service.js
+++ b/srv/travel-service.js
@@ -135,6 +135,7 @@ init() {
this.before ('SAVE', 'Travel', req => {
const { BeginDate, EndDate, BookingFee, to_Agency_AgencyID, to_Customer_CustomerID, to_Booking, TravelStatus_code } = req.data, today = (new Date).toISOString().slice(0,10)

+ if (req.method !== 'PATCH' ) //[@TODO] disable validation for mass edit demo
// validate only not rejected travels
if (TravelStatus_code !== 'X') {
if (BookingFee == null) req.error(400, "Enter a booking fee", "in/BookingFee") // 0 is a valid BookingFee
MioYasuatke
Active Contributor
0 Kudos

Upgrading @Sap/cds version to 7.6.1 resolved the issue.

Marian_Zeis
Active Contributor
0 Kudos
Was already with 7.5 3 🙂
gregorw
Active Contributor
0 Kudos

20eed143c19f4b82bc4cf049916102cb posted Feature bypass_draft in CAP not working on POST a while ago and filed a case 1167783 / 2023. Today he got the information that the issue should be fixed in CDS 7.6.

Dinu
Active Participant
0 Kudos

Dear @ gregor.wolf,

Thanks for the information. I understand Marian Zeis's post is about a hand-crafted POST request. I am not looking for anything special like that.

My interest is to have a working sample of what is shown in the demonstration in the release notes. Are you aware of any sample that can be used to reproduce the demonstration of this feature with Fiori Elements based user interface? I'm not looking for anything special. Just reproducing the demonstration as it is in the animation. There are so many variations of cap_sflight in several sample repositories. Perhaps one of the published versions is used for this demonstration?

Regards,

Dinu