SAP / cloud-sdk-js

Use the SAP Cloud SDK for JavaScript / TypeScript to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
167 stars 57 forks source link

Cannot update DateTime field if the original value is null #1663

Closed yurecz closed 3 years ago

yurecz commented 3 years ago

Describe the bug I am trying to update the OData entity date field with definition:

with date/time value = moment(), the original value is null.

To Reproduce Steps to reproduce the behavior:

  1. Try to update the entity field DateTime with null value
  2. Execute Odata update, for example CustomerDelivery.requestBuilder().update(delivery).execute(...)
  3. Get the error log below

Expected behavior It should be possible to set the date/time field even if the original value is null.

Used Versions: node v12.18.3 npm 7.20.3 SAP Cloud SDK 1.47.1

Code Examples If applicable, add code snippets as examples to help explain your problem. Please remove sensitive information.

Log file And The visit to customer SDD_01_001 is released for settlement # node_modules\cucumber-tsflow\src\binding-decorator.ts:190 TypeError: Cannot convert undefined or null to object at Function.keys () at equalObjects (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\util\src\equal.ts:9:24)
at Object.equal (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\util\src\equal.ts:29:12)
at C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\entity.ts:264:30
at Array.filter () at CustomerDelivery.Entity.getUpdatedPropertyNames (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\entity.ts:264:15) at getFieldNames (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\entity-serializer.ts:138:18) at serializeEntityNonCustomFields (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\entity-serializer.ts:115:12) at Object.serializeEntity (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\entity-serializer.ts:71:10) at UpdateRequestBuilder.serializedDiff (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\request-builder\update-request-builder-base.ts:276:32) at UpdateRequestBuilder.getPayload (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\request-builder\update-request-builder-base.ts:231:23) at UpdateRequestBuilder [as constructor] (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-common\request-builder\update-request-builder-base.ts:55:39) at new UpdateRequestBuilder (C:\LMD\lmd-dragons-continuous-integration-functional\integration\node_modules\@sap-cloud-sdk\core\src\odata-v2\request-builder\update-request-builder.ts:45:5) at CustomerDeliveryRequestBuilder.update (C:\LMD\lmd-dragons-continuous-integration-functional\integration\proxies\lmd-route-service\Custo at CustomerVisitSteps. (C:\LMD\lmd-dragons-continuous-integration-functional\integration\step-definitions\lmd-route-customer-vi at step (C:\LMD\lmd-dragons-continuous-integration-functional\integration\step-definitions\lmd-route-customer-visit.steps.ts:39:23)

jjtang1985 commented 3 years ago

Hi @yurecz ,

thanks for raising this up. I can reproduce it.

Could you please share the urgency and the project status (e.g., Go-live or PoC)?

Best regards, Junjie

yurecz commented 3 years ago

Hello Junjie,

It is urgent in the sense that the S/4HANA test automation PoC is not working with cucumber as the test tool and SAP cloud SDK as OData client. Currently, I am trying to use the workaround by changing the content of the null DateTime fields to some default dates.

Best regards, Yuri

jjtang1985 commented 3 years ago

Hi @yurecz,

I created a backlog item for fixing the bug. FYI @artemkovalyov .

Best regards, Junjie

deekshas8 commented 3 years ago

Hi @yurecz , The bug was fixed. You can try the canary version to test it out and a new stable version will be released soon. Thanks.

yurecz commented 3 years ago

Yes, it works in the canary version.

Best regard, Yuri