on 2024 Oct 29 9:23 AM
Hi Experts!
GoodDay!
This issue was raised in between the development (when adding attachment feature to my CAP application – used @cap-js/sdm library as mentioned in CAPIRE documentation)
Below is the structure of my header and attachment entity.
InvoiceHeader – Entity
Attachment – Entity
I’ve implemented a custom handler for InvoiceHeader entity on Update event.
I’m running my application in a hybrid mode and I’m opening my annotated UI application (built using FPM). When trying to edit a record and saving it showing me the below error.
EKEYTYPE: The key argument has to be of type `string` or `number`. Found: `undefined`
When I’m debugging it, the error was coming from the SELECT statement (which was working previously) line no.103 like in the below screenshot. However the query executed successfully where you can see the result in aHeaders variable.
I’m sure “ID” is the only key for InvoiceHeader Entity and the value is coming via “req.data.ID” parameter.
I’m trying to figure it out, I’m not sure where I’m lagging.
Help me to resolve this issue.
Thanks in Advance!!
Best Regards
Boopalan M
SAP Business Application Studio , SAP Cloud Application Programming Model ,
Request clarification before answering.
Hi @Boopalan ,
Have you tried the complete configuration as described in the documentation?
I just tried the setup you described. I received the same error message you do by just adding the npm library and extending the model with the extra attachments field.
In debug I see, that the referenced id in the error message is the repository id of the sdm repository (SAP Document Management).
I added the following configuration to the package.json:
"sdm": {
"settings": {
"repositoryId": "<repository-Id>"
}
}and I stopped getting the error message.
Regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed, in my case I had a wrong repository ID set. Just for reference, from the docs:
Create a SAP Document Management Integration Option Service instance and key. Using credentials from key onboard a repository and configure the onboarded repositoryId under cds.requires in package.json. Currently only non versioned repositories are supported.
Hi @Boopalan ,
Could you take a look at the Serving Media Data topic in the documentation?
entity Books { //...
image : LargeBinary @Core.MediaType: imageType;
imageType : String @Core.IsMediaType;
}Maybe that's what you are looking for instead of the attachments and sdm plugins.
Regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Boopalan ,
Have you tried to remove the key keyword from Parent? The Attachments entity itself already has a key ID inherited from the cuid aspect.
I haven't tried your whole setup, but as a first shot maybe could you try like this?
entity C_Attachment : Attachments {
name: String;
Parent: Association to one InvoiceHeader;
}Also the Attachments has a filename property inherited from the MediaData aspect if you could use that.
You can inspect all the aspects of the Attachments entity in Business Application Studio / VSCode by Ctrl + Click in Win (or Cmd + Click in Mac)
Regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @catano
I've tried what you've mentioned. However, it didn't help me resolve the issue.
Thanks for the suggesting the aspects. The name : String is experimental.
Do you have any other idea?
Best Regards,
Boopalan M
@catano, it is showing the error as before. When I remove the attachments composition from the header entity, it is working as expected while update event.
I've followed the same step as mentioned in the documentation CAP Plugins & Enhancements | capire
Rather than wrapping the Attachment aspects in C_Attachment, I've made the direct composition of Attachment aspect to attachments field in Header entity.
Screenshot for your reference
however, it is showing the same error at the select statement as before.
Is it a bug in CAP? or am I missing something important?
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.