Has anyone figured out a workaround for updating a relationship field or creating a record with a relationship field?
I have an external form and I want to feed the responses of that form into a collection on Adalo. One of the properties of the collection is a relationship field but when I try to run this in Integromat it just winds up empty.
I also tried updating as opposed to creating a new record but it’s the same thing.
I would really appreciate any help, it’s super important.
I don’t see any problems in updating a relationship field in Integromat. This will work if you are updating a record in 1:many relationship which is on the “many” side (assigning this this record to a certain “parent” record).
E.g.: you have Items and Categories, one Item belongs only to one Category (and Category can have many Items). In Integromat, you can update a record in Items collection, and assign a relationship of this Item to a certain Category. What you need to do is to simply put Category id to the relationship field.
You can not assign multiple items to a Category in this relationship - this isn’t supported by Adalo API.
If you have many-to-many relationship, as I remember you can assign multiple relationships in a field, using array. But I don’t have an example at hand so tests are needed.
Thanks @Victor the video was super helpful. My scenario is slightly different, but I was able to get the first 2 steps done. I have my trigger (update to a Google Sheet), I then isolate the correct record, but when I update the record I get the following error. Not sure if you have any ideas on what I’m doing wrong. The relationship I want to update is many to many between users and programs.
My video was about 1:many relationships. Many-to-many should be done a little bit differently.
As I see, Adalo API expects to get an array when updating this field type. So you need to create an array with values an put it into this field.
If you just want to “erase” previous relationships, you can put something like: add ( emptyarray ; XX ; YY), where XX and YY are the IDs of the records to be added.
If you would like to keep previous relationships, you need to do something like this:
Here I have created a M2M relationship between Users and Examples. On the previous module #6, I get Example record (via List records). And here I modify Users field, by:
firstly Merging an existing array with emptyarray (why: if there are no relationships → array won’t exist → the field won’t be updated).
and then adding the desired IDs to the resulting array.
Hope this helps.
Maybe I will make video about this - when I have some time…
Just in case: Adalo doesn’t provide any official documentation about updating relationships via API, so this is kind of “undocumented” feature. Use it on your own risk