cancel
Showing results for 
Search instead for 
Did you mean: 

CAP (Node.js) - "[cds] - TypeError: Cannot read properties of undefined (reading 'isAssociation')"

itsvivek_r
Discoverer
0 Kudos

Hi, Currently im working on a CAP Project;

Model:

model.txt

Service:

service.txt

The Application is working fine, the drafts are enabled and its getting saved. I'm Using SAP HANA Cloud for storing the records.

Issue:

The Issue is i couldn't create the records:

The actual error appear in terminal:

[odata] - HEAD /odata/v4/service-catalog/ 
[odata] - GET /odata/v4/service-catalog/$metadata?sap-language=EN 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > READ ProductDetails {
  '$count': 'true',
  '$filter': '(IsActiveEntity eq false or SiblingEntity/IsActiveEntity eq null)',
  '$select': 'CreatedAt,CreatedBy,CurrencyCode,HasActiveEntity,IsActiveEntity,ModifiedAt,ModifiedBy,Price,ProductCategory,ProductDescription,ProductId,ProductManufacturer,ProductName,Quantity',
  '$skip': '0',
  '$top': '30'
}
[pool] - effective pool configuration: {
  min: 0,
  max: 100,
  testOnBorrow: true,
  fifo: false,
  acquireTimeoutMillis: 10000,
  softIdleTimeoutMillis: 30000,
  idleTimeoutMillis: 30000,
  evictionRunIntervalMillis: 60000,
  numTestsPerEvictionRun: 34
}
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > CANCEL ProductDetails(ProductId=f1f58eb1-4b91-442e-8d57-f0f9e4a893d6,IsActiveEntity=false) 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > READ ProductDetails {
  '$count': 'true',
  '$filter': '(IsActiveEntity eq false or SiblingEntity/IsActiveEntity eq null)',
  '$select': 'CreatedAt,CreatedBy,CurrencyCode,HasActiveEntity,IsActiveEntity,ModifiedAt,ModifiedBy,Price,ProductCategory,ProductDescription,ProductId,ProductManufacturer,ProductName,Quantity',
  '$skip': '0',
  '$top': '30'
}
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > NEW ProductDetails 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > READ ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false) {
  '$select': 'HasActiveEntity,HasDraftEntity,IsActiveEntity,ProductCategory,ProductDescription,ProductId,ProductManufacturer,ProductName,Quantity',
  '$expand': 'DraftAdministrativeData($select=DraftIsCreatedByMe,DraftUUID,InProcessByUser)'
}
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > PATCH ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false) 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > PATCH ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false) 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > PATCH ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false) 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > PATCH ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false) 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > PATCH ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false) 
[odata] - POST /odata/v4/service-catalog/$batch 
[odata] - > draftPrepare ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false)/ServiceCatalog.draftPrepare 
[odata] - > draftActivate ProductDetails(ProductId=f6358804-478c-4033-96dc-dbcf2b740cff,IsActiveEntity=false)/ServiceCatalog.draftActivate {
  '$select': 'HasActiveEntity,HasDraftEntity,IsActiveEntity,ProductCategory,ProductDescription,ProductId,ProductManufacturer,ProductName,Quantity',
  '$expand': 'DraftAdministrativeData($select=DraftIsCreatedByMe,DraftUUID,InProcessByUser)'
}
[cds] - TypeError: Cannot read properties of undefined (reading 'isAssociation')
    at _newNestedData (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:95:23)
    at _newData (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:151:9)
    at /home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:277:24
    at Array.map (<anonymous>)
    at _newEntries (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:277:11)
    at _newInsert (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:467:46)
    at _newQuery (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:733:42)
    at resolveView (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:752:20)
    at _convertInsert (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/cqn2cqn4sql.js:869:10)
    at cqn2cqn4sql (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/cqn2cqn4sql.js:1007:12) {
  id: '1280614',
  level: 'ERROR',
  timestamp: 1704305127209
}
[cds] - ️Uncaught TypeError: Cannot read properties of undefined (reading 'isAssociation')
    at _newNestedData (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:95:23)
    at _newData (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:151:9)
    at /home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:277:24
    at Array.map (<anonymous>)
    at _newEntries (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:277:11)
    at _newInsert (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:467:46)
    at _newQuery (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:733:42)
    at resolveView (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/resolveView.js:752:20)
    at _convertInsert (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/cqn2cqn4sql.js:869:10)
    at cqn2cqn4sql (/home/user/projects/CAP_Products/node_modules/@sap/cds/libx/_runtime/common/utils/cqn2cqn4sql.js:1007:12) {
  id: '1280614',
  level: 'ERROR',
  timestamp: 1704305127209
}

From this i can understand, the app can make POST / $batch call; but, seems like its failing due to some reason.

As i'm new to SAP CAP, i couldn't judge whats the actual issue going; may be some of the assosiations went wrong or needs little amendments.

can anyone help me on this error?

Thanks for your Valuable responses,

Regards,

Vivek

gregorw
Active Contributor

please format all the code snippets.

hjb
Advisor
Advisor
0 Kudos

Hi, thanks for reporting this, I'll forward this to my colleagues.

Accepted Solutions (0)

Answers (1)

Answers (1)

johannesvogel
Advisor
Advisor

Hi Vivek,

within your Products View, you flatten elements of the associated entities Categories, Manufacturers.

That's not supported for draft enabled entities as associated entities are not part of the draft object.

If you use Products as your main entity instead, it should work as expected.

Alternatively, you can mark those elements as read-only.

Best regards,

Johannes