Compare lists AND how to correctly use storage

I need a little help with this flow, please!

Goal: I get data from a form. That includes a multi-select field where users can select from a list of groups to be added to. I use a loop and an HTTP call to add the user to the selected groups 1 by 1. Once I’m done, I make another HTTP call to the API to get the user details, which will list all the groups they are in. I want to verify the user is added to all the groups they selected as well as identify any groups they are in that were not selected.

Here’s what I have so far:

  1. Get the form data
  2. Convert the multi-select field to CSV, then JSON.
  3. Run a loop on the JSON list of groups.
  4. Call the API add user to groups via HTTP
  5. After the loop is finished, I make another HTTP call to get user data, which lists all the groups they are in.
  6. Loop through the http response to identify all groups the user is in.

But I need some help identifying any discrepancies. (There are two possible types: groups they should be in, but are not, and groups they are in, but should not be.) So, I need a way to compare step 6 to step 3 and identify differences.

For instance: user selects Groups A,B,C,D. I add them to those groups. But then the final call shows the user in groups C,D,F. So, they should be in A and B and not in F.

Make sense?

I thought I might be able to use storage:add in my first loop to add each group to a run-specific storage item, then use storage:remove in my 2nd loop to remove each group that they actually are in. But I clearly don’t understand how the storage piece works, as I keep ending up with an array that is all the groups: 0:{"1":"General Library Notifications","2":"‌Cardinal Ridge","3":"‌EagleView","4":"‌Golden Eagle"}

And even if this worked, I think it only solves half my problem, as it would only show me the groups that they are in, but shouldn’t be. It doesn’t show the groups they should be in but are not.

Here’s an example of the data from step 3:
{
“index”: 1,
“item”: {
“1”: “General Library Notifications”,
“2”: “‌Cardinal Ridge”,
“3”: “‌EagleView”,
“4”: “‌Golden Eagle”
}
}

And the data in Step 5:
{
“status”: 200,
“headers”: {
“date”: “Wed, 24 Jul 2024 16:58:26 GMT”,
“server”: “Apache”,
“x-powered-by”: “PHP/8.1.29”,
“strict-transport-security”: “max-age=15552000; includeSubDomains”,
“x-permitted-cross-domain-policies”: “none”,
“referrer-policy”: “no-referrer”,
“x-content-type-options”: “nosniff”,
“x-frame-options”: “SAMEORIGIN”,
“upgrade”: “h2,h2c”,
“connection”: “Upgrade, close”,
“vary”: “Accept-Encoding”,
“content-length”: “263”,
“content-type”: “text/html; charset=UTF-8”
},
“body”: {
“status”: “0”,
“contacts”: [
{
“id”: 9,
“name”: “”,
“birthday”: “0000-00-00”,
“email”: “”,
“number”: “USERNUMBER”,
“group”: “Brookridge Heights Apartments”,
“subscriber”: “Yes”,
“source”: “Import”,
“carrier”: null,
“date”: “2024-07-24 11:57:31”
},
{
“id”: 9,
“name”: “”,
“birthday”: “0000-00-00”,
“email”: “”,
“number”: “USERNUMBER”,
“group”: “Cardinal Ridge”,
“subscriber”: “Yes”,
“source”: “Import”,
“carrier”: null,
“date”: “2024-07-24 11:57:31”
},
{
“id”: 9,
“name”: “”,
“birthday”: “0000-00-00”,
“email”: “”,
“number”: “USERNUMBER”,
“group”: “Fake Group”,
“subscriber”: “Yes”,
“source”: “Import”,
“carrier”: null,
“date”: “2024-07-24 11:57:31”
},
{
“id”: 9,
“name”: “”,
“birthday”: “0000-00-00”,
“email”: “”,
“number”: “USERNUMBER”,
“group”: “Golden Eagle”,
“subscriber”: “Yes”,
“source”: “Import”,
“carrier”: null,
“date”: “2024-07-24 11:57:31”
},
{
“id”: 9,
“name”: “”,
“birthday”: “0000-00-00”,
“email”: “”,
“number”: “USERNUMBER”,
“group”: “General Library Notifications”,
“subscriber”: “Yes”,
“source”: “Import”,
“carrier”: null,
“date”: “2024-07-24 07:22:42”
}
]
}
}

So, in that example, the user should be in:
General Library Notifications
Cardinal Ridge
EagleView
Golden Eagle

But, is in:
:x:Brookridge Heights Apartments
Cardinal Ridge
:x:Fake Group
Golden Eagle
General Library Notifications

So, the end result of this flow should be data that shows me that the user is in 2 groups they shouldn’t be and is not in EagleView, which they should be in.

Here’s my flow:

Ended up using code steps to parse the data into usable formats and got this all figured out.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.