Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

Insert or Update using xtk.session.Write

Avatar

Level 3

Hi,

Can anyone please confirm if the below approach is correct if we want to insert or update the data in a table using JS?

 

insertUpdateQuery = <order _key="@custId,@productName,@subProductName" _operation="insertOrUpdate"  xtkschema = "cus:order"
productName = { productName }
subProductName = { subProductName }
custId = { custId }
productid= { productid}
datetime = { datetime }
/>
xtk.session.Write(insertUpdateQuery);

 

We are getting duplicate key value violates unique constraint errors in logs as during insertion or updation we can get data that might be already present based on the 3 key fields.

Based on my understanding if we use insertorUpdate operation it should not give a duplicate error. Can anyone please with this?

Version is V8

Thanks 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

Hi @ratika ,

 

Your write function and understanding related to "insertOrUpdate" operation are correct, as if there is a value that exists post the reconciliation of _key then the "insertOrUpdate" will update that record else it will insert.

Did you try to run the same js function in any other workflow to check if there are any caching/corruption issues in the current wkf?

Also, did you try to use _operation="update" (for testing) to observe if this also returns the same error of duplicate key?

 

Br,

Shubham

 

Avatar

Administrator

Hi @ratika,

Were you able to resolve this query or do you still need more help here? Do let us know.

Thanks



Sukrity Wadhwa