Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add custom fields/logic to Attachments entity #65

Open
Zahlii opened this issue Jun 12, 2024 · 2 comments
Open

Cannot add custom fields/logic to Attachments entity #65

Zahlii opened this issue Jun 12, 2024 · 2 comments
Labels
author action bug Something isn't working

Comments

@Zahlii
Copy link
Contributor

Zahlii commented Jun 12, 2024

using {Attachments} from '@cap-js/attachments';
// also using {Attahcment as BaseAttachments} and naming our entity Attachments : BaseAttachments same error


entity UIAttachments : Attachments {
    approvalStatus                  : Association to cdh.Status @readonly;
}

entity Bla {
  attachments                             : Composition of many UIAttachments;
}

Results in:

[cds] - ❗️Uncaught TypeError: Cannot read properties of undefined (reading 'xpr')
    at _addKeysToData (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:67:22)
    at _addKeysToData (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:69:12)
    at _addForeignKeys (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:159:5)
    at getData (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:284:5)
    at new ODataRequest (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js:141:20)
    at /Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js:27:13
    at /Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js:135:7
    at new Promise (<anonymous>)
    at Dispatcher._handle (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js:134:12)
    at Dispatcher.dispatch (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js:97:21) {
  id: '1350143',
  level: 'ERROR',
  timestamp: 1718184547532
}
@Zahlii
Copy link
Contributor Author

Zahlii commented Jun 12, 2024

I was able to work around this by simply extending the given Attachments entity:

extend Attachments with {
    approvalStatus                  : Association to cdh.Status @readonly;
}

@muskansethi1 muskansethi1 added the bug Something isn't working label Sep 27, 2024
@muskansethi1
Copy link
Contributor

muskansethi1 commented Oct 7, 2024

Hi @Zahlii,
I am not able to reproduce this error with the latest versions of the packages. Can you please confirm if this issue is still valid?

Best Regards,
Muskan Sethi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author action bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants