dirigible icon indicating copy to clipboard operation
dirigible copied to clipboard

[EDM] Cannot create entity with calculated timestamp from the TypeScript

Open iliyan-velichkov opened this issue 1 year ago • 4 comments

During the Electra inbound synnchronization, I'm trying to create a Customer entity with the following fields: image image

using the following code: image image

but the DAO fails to validate it becaue there is no DateAdded.

org.graalvm.polyglot.PolyglotException: Error: Illegal DateAdded attribute value in CODBEX_CUSTOMER entity: undefined
	at <js>.DAO.validateEntity(./dao:274) ~[na:na]
	at <js>.DAO.update(./dao:377) ~[na:na]
	at <js>.update(../../../../codbex-electra/gen/dao/Customers/CustomerRepository:42) ~[na:na]
	at <js>.upsert(../../../../codbex-electra/gen/dao/Customers/CustomerRepository:61) ~[na:na]
	at <js>.handle(merge-customer-from-open-cart.js:26) ~[na:na]
	at <js>.onMessage(merge-customer-from-open-cart.js:8) ~[na:na]
	at org.graalvm.polyglot.Value.execute(Value.java:881) ~[polyglot-23.1.1.jar!/:na]
	at org.eclipse.dirigible.graalium.core.DirigibleJavascriptCodeRunner.runEsmMethod(DirigibleJavascriptCodeRunner.java:193) ~[dirigible-engine-graalium-execution-core-11.0.0-SNAPSHOT.jar!/:na]
	at org.eclipse.dirigible.graalium.core.DirigibleJavascriptCodeRunner.runMethod(DirigibleJavascriptCodeRunner.java:186) ~[dirigible-engine-graalium-execution-core-11.0.0-SNAPSHOT.jar!/:na]
	at org.eclipse.dirigible.components.engine.camel.invoke.Invoker.invoke(Invoker.java:41) ~[dirigible-components-engine-camel-11.0.0-SNAPSHOT.jar!/:na]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]

I expect that this field should be calculated if there is no existing entry (Create) and remain the same if it is an update.

iliyan-velichkov avatar Feb 20 '24 08:02 iliyan-velichkov

As workaround, I will just remove the "Not Null" for all DateAdded columns in the edm for now.

iliyan-velichkov avatar Feb 20 '24 08:02 iliyan-velichkov

@iliyan-velichkov I'm not 100% that this would help, but could you try to change the expression from:

Date.now()

to

new Date()

As the first returns a number and the second returns a Date object.

ThuF avatar Feb 27 '24 16:02 ThuF

@iliyan-velichkov I'm not 100% that this would help, but could you try to change the expression from:

Date.now()

to

new Date()

As the first returns a number and the second returns a Date object.

I think this was failing because there is no field DateAdded not because its value is wrong.

iliyan-velichkov avatar Feb 28 '24 07:02 iliyan-velichkov

@iliyan-velichkov Okay now I see that the value in model for Calculated property expression for Update is empty and in the example you are doing upsert() which results in a update(). Could you check if by adding the expression for update would solve the issue?

ThuF avatar Feb 28 '24 09:02 ThuF