When trying to update records from WebRequest - UniquenessConstraintError

Hi,

I’m trying to update customers records in a object class “customer” using with reading all records to a runtime only object class Customer (temp). The action is runs on a service triggered from the app.

Running this when the table is; empty every thing works as expected, but
When I run it a second time to update the records we already have; I get this error: UniquenessConstraintError: Found equal values among persisted objects.

In the web request I have checked the boxes for update existing and add to existing. The action ends with a persist of Customer (temp)

Any suggestion on how to fix this or is it a bug?

Hi,

Sorry for the late response!

It seems as though this occurs because of the uniqueness requirement on the mapping property, which in this case is (assuming) refNo. Create does not match Appfarm-ID on existing objects to external ID’s. This leads to Create assuming that these are new objects, which will result in the following Persist to fail as this will collide with the uniqueness requirement.

A suggestion is to carry out this mapping in the result parser instead, which will avoid the generation of new objects.

Let us know if this helps!

Hi!

Just a small question: Does that “Customer (temp)” datasource contain all existing customers before that web request is performed? It must do so in order for the “Mapping property” feature to work: That feature should look for a customer with that refNo inside that datasource (and update if it exists, and create it if not). Otherwise, a new customer with that refNo will be created into that runtime datasource, and the uniquenessconstraint will be encounter when persisting.