WITH_ITEM() with 2 unexpected validation warnings - do you know the reasons❓

Hello Guys,
I thought I had validated all major tough steps but there’s still one. It’s the mountain hiding behind the forest… :sweat_smile:

I’m using WITH_ITEM(appVars.services, data.addService.services) in an appVars which is set as a list of objects with 9 properties and is triggered after an Update record function.
The “item to add” inside that formula is the data.addService.services passed to the Update record function. The data variable ‘addService’ is also set as a list of objects with 9 properties.

But I get 2 validation warnings:
:warning: List type is not assignable to object type => which object? I work with list!
:warning: List items are incompatible => why? The doc does specify that “The item must match the schema of the list”, wihich they do in my case.

FYI I want to let users add an additional object with 9 properties to the list “services” in the same document each time they input data into the 9 input fields and hit the save button that fires an Update record flow function.

In the uodate record You update an object which has the list as a property. So you should set the value to this:

SET_KEY(yourdatarecord, “listofservices”, WITH_ITEM(what you have above))


1 Like

Oh I see how it works now.
With WITH_ITEM(my_list_to_add_item_to, item_to_add) we update the list with the new item so we have the list with new data.
Then with SET_KEY (my_document_object_which_contains_the_list, the_list_to_change, the_list_with_new_data) we apply the list with new data to the right list inside the right document.
I can’t verify that it works because I haven’t build the functionality yet, but I get it, it makes sense.

Speaking of building the functionality, based on your experience, shall I have a separate flow for letting user update a previously created document (with Update record function) by adding a first service (list with one object created), and then a flow (a separate Update record function) for letting user add one more service (one more object inside the list) each time a separate ‘save’ button is hit? Or is it possible / recommended to have one flow (one update record) that updates the document by adding a first service when it’s the first one then that updates the services list when there’s already a list?

You can pack those into one flow. It would be something like this:
If flow that check if the list is empty.
-true: add all new services as a new list in the update record as a simple SET_KEY(data, “listtoasignto, listthathasvalies)
-false: do the SET_KEY(data, listtoassignto, WITH_ITEM(….)) or if you want to add multiple objects at the same time You can use the UNION(listtoassignto, listwhichtoadd). This would make a new list with unique items feom both lists.

1 Like

Too complicated for this flow but I’ll use the condition in the dashboard where I let users add, update, delete up to 3 services.