cancel
Showing results for 
Search instead for 
Did you mean: 

Localized tables in CAP have no draft functionality

T1mey
Participant
0 Kudos

Background: 

We have a CAP Service and a UI5 Application, that creates/maintains a text (and some other fields). 
We want our Frontend to be able to maintain this text in multiple languages, therefore we indicated this field as localized in our db/data-model.cds file: 

 

using { cuid, managed } from '@sap/cds/common'; 

namespace com.websol; 

 

annotate FormattedText with @assert.unique: { 

FormattedText: [ 

    scenario, 

    priority 

  ] 

}; 

 

entity FormattedText: cuid, managed { 

@mandatory scenario: String; 

@mandatory priority : Int16; 

@mandatory value : localized String; 

@mandatory validFrom: Timestamp; 

@mandatory validTo: Timestamp; 

  } 

 

For testing purposes we adapted our srv/maintain-service.js to add hardcoded translations for now on the CREATE event (later we want to add translations via Translation API) like this: 

 

const cds = require('@sap/cds') 

const { timeStamp } = require('console') 

const { text } = require('express') 

const { uuid, read, fs, path, decodeURI } = cds.utils 

 

module.exports = function () { 

    // this.on('submitOrder', (req) => {...}) //> custom actions   

    this.before('CREATE', `FormattedText.drafts`, (req) => { 

 

        req.data.ID = uuid() 

        req.data.texts = [{ "ID": req.data.ID, "value": "Ein Name", "locale": "de" }, 

        { "ID": req.data.ID, "value": "A name", "locale": "en" }] 

 

    }) 

} 

 

When we create a new entry, the translations exist in the localized database (com_websol_FormattedText_texts) but as soon as we Save the draft they disappear! 

We assume this is because the localized table seems to have no draft functionality, since we only have the following tables: 

 

  • DRAFT_DraftAdministrativeData 
  • MarkdownMaintainService_FormattedText_drafts 
  • com_websol_FormattedText 
  • com_websol_FormattedText_texts 

 

 

Additional Screenshots: 

This is how the object page looks like, when creating a draft: 

T1mey_0-1713190035888.png

 

 

 

This is after saving (the database reflects the same): 

T1mey_1-1713190035899.png

 

 

 

View Entire Topic
Dinu
Contributor