Web request overwrites runtime object

The “Add to existing object” does not seem to work as i expect. No matter what I do it always creates a new runtime object, instead of modifying the existing one.

The following images are from dev:



Even with this toggled, it still creates a new object in the datasource, instead of modifying the exisitng object as I want

image

Hi!

In your latter screenshot - behind that information box - what are the settings?

Since Unit (RT) is a data source holding multiple objects, it might be correct with both “Add to Existing” and “Update Existing” checked. In this case, objects returned from the web request will be added to the Unit (RT) data source (as new records) if they are not present in that data source already, but if they already are, those existing objects will be updated. However, you need to set the Mapping Property (see screenshot) to tell the web request which property it will use to check if an object returned exists in the Unit (RT) data source.
image

However: based on your screenshot and the fact that it states “accessToken”: To me it sounds as if the cardinality of “Unit (RT)” might be wrong, and that it should be a single cardinality data source. In this case, you would only need to tick “Update Existing” without stating any Mapping Property (since only 1 object is present, the web request knows which one to update).
image

I have tried both options, cardinality one and many. None updates the object.

With cardinality one, you can clearly see that the old object has been replaced with a new one (ID is new and authorization is gone), see images below. The authorization is the result of a post call, and problems arise when the authorization disappears. I have now made a holder-class, with the purpose of being a middleman between the API calls. This is however not my desired approach.
image

With cardinality Many, how does the Mapping property work?
Say I map it to ID, and ID exist in the results from the API-call. There will also be a lot more in the respons, so how does appfarm know what to map to the “mapping property”?

Example respons:
{
“unitName”: “string”,
“observations”: [
{
“name”: “string”,
“description”: “string”,
“data”: 0,
“measurementUnit”: “string”,
“timestamp”: “2024-03-19T11:00:12.542Z”
}
]

What happens if my object has a property called UnitID, which correspond to unitName in the respons?

Hi!

I have verified that the log displays incorrect in this case, where you update existing object with a web request. It logs out a (temporary, but discarded) object, and then updates the existing object.

In my screenshot:
Web Request 1: Creates a new object in data source Project (temp).
Web Request 2: Updates the object in the same data source.

Can you expect the values of the “Results_mapping” data source in the “App Data” submenu of the Developer Tool instead?

With regards to your second question: If you have a web request returning 10 customers, and want to match on the internal object class property Cust No, and you get “customerNumber” from the JSON response, you need to

  1. Select Cust No as Mapping Property
  2. Enter “customerNumber” in the Property Mapping for the Object Class Property Cust No.
    As in this example:
    image

(the documentation of the Web Request result mapping has been updated with these settings now)

Thanks for the clarification! :slight_smile:

You are correct, the debug window caused the confusion. Many cardinality have I not yet tried but i suspect the error was due to incorrect mapping property like you suggest

1 Like