Hello. I am trying to fetch user data from my backend and compare the rows based on their ID with google sheet data. I need to update any data that’s already present in the google sheet and add the new users.
I am first fetching all rows from the google sheet and am using Array aggregator to create an array with just ids and row numbers. Then I am fetching users, and using an iterator and a router to check which need updating/adding.
What is the problem & what have you tried?
I have an issue with a condition to check if the item’s ID from iterator is already in the array. I am trying to use a map function on the array with contains filter, but getting an error. The raw key of ID seems to be 0, but that keeps resulting in an error.
Error messages or input/output bundles
Failed to evaluate filter ‘0-0’: Function ‘map’ finished with error! Cannot read properties of undefined (reading ‘0’)
The problem is the field reference. In map() you need to use the field name, not the raw key number.
Your aggregated items have keys like id and Row number. When you use 0, Make tries to read a field literally called 0, which does not exist, so you get the “reading 0 of undefined” error.
Use the id field instead. For example:
map(54.Array[]; id)
Then in the router condition just check whether that mapped array contains the current user ID from the iterator.
So the fix is simply replacing 0 with id in the map function.
Dr. Tanvi Sachar
Monday Certified Partner, Tuesday Wizard
Thanks for a quick response!
I tried using id and id (A) now. I am no longer getting the error, however, I ran it three times with the same values in the iterator and they are always passing the “Does not contain” condition, so I always get new rows instead of updating the existing ones. Any idea what else might be incorrect?
Here’s a part of my output data from array aggregator: [
{
“array”: [
{
“0”: 67,
“ROW_NUMBER”: 2
},
{
“0”: 9527,
“ROW_NUMBER”: 6055
},
{
“0”: 9527,
“ROW_NUMBER”: 6060
},
{
“0”: 9528,
“ROW_NUMBER”: 6056
},
{
“0”: 9528,
“ROW_NUMBER”: 6061
}
],
“IMTAGGLENGTH”: 6060
}
]
And one object from the output data from my iterator:
[
{
“id”: 9528,
“created_at”: 1758866419826,
“role”: null,
“finished_profile”: false,
“registered”: false,
“where_from”: “”,
“marketing_consent”: false,
“automatic_transition_from_student”: false,
“needs_update_after_transition”: false,
“source”: “luma”,
“non_medic”: {
“work_at”: “”,
“role”: “”
},
“file_cover_letter”: null,
“file_cv”: null,
“_IMTINDEX_”: 1,
“_IMTLENGTH_”: 5
}, …. ]
Fixed it - I indeed had to reference the key by its raw value - 0. So my intial map was correct. There seems to be some sort of a bug however, when the map didn’t work when used in a Router module. It kept returning empty values, so the filter would never work.
I added a variable with the same map, and that returned an array of ids correctly. Once I used the variable in a Router, the conditions were finally passing.