Compare 2 arrays and return items with properties that are different

:bullseye: What is your goal?

Hi everyone. I am working on a simple scenario that pulls a list of Xero Accounts into a Data Store. As part of this scenario I want to add a branch where a record is updated in Data Store if either the “name” or “type” in Xero is different than what’s currently in Data Store.
The Array from Xero contains quite a few properties out of which I only need XeroID, Name, Type and Status and this also replicated in Data Store. The key in Data Store is actually the XeroID.

:thinking: What is the problem & what have you tried?

I can’t seem to figure out how to compare the 2 arrays. I was searching for something similar to a lookup, so when I look if the ID in Xero exists in Data Store then check that name and type matches. If not, update Data Store with the new details.

I’ve been looking at doing this at an array level rather than each individual account, because it will consume a lot of credits and I’d like to use this approach on other scenarios that need to run daily.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

[XERO - DS] GL Codes.blueprint.json (29.7 KB)

Right now, I don’t think there is a true “array level lookup and diff by property” in Make.com and you will always end up iterating somewhere.

The clean way to handle this:

  • Treat the Data Store as your current state.

  • Treat Xero as your source of truth.

  • For each Xero account, look up the matching record in the Data Store by XeroID and only update when the name or type changed.

That gives you the “only update changed records” behavior without trying to do clever array-to-array comparison.

I hope this helps you!

Welcome to the Make community!

In addition to what @Karmic wrote above, if you still require array-to-array comparison, the most cost-effective way is to use a Make Code module with some custom code.

If you are still having trouble, please provide more details, including output bundles of both arrays.


If you need further assistance, please provide the following:

1. All Relevant Screenshots

We need to see what you’re working with to give you the best advice. Screenshots are important because Make is a visual editor — a picture provides us with more context.

It would help us identify the issue by having screenshots of:

  • the full scenario, and the zoomed in parts of the scenario that you are referring to (if your scenario is huge),
  • a full scenario run/execution from the history (showing output “speech” bubbles),
  • relevant module fields (showing how you’ve used any built-in functions, and how you’ve mapped the variables),
  • relevant filters between modules (showing which operators and any built-in functions you’ve used, and how you’ve mapped the variables),
  • relevant module input/output bubbles,
  • if applicable, any error messages,
  • and if applicable, any external services (spreadsheet headers/ sample data/ regex101.com/ etc. to show the item/ record exists, and is set up correctly).
Need help❓View instructions ◀

We would appreciate it if you could directly upload screenshots here instead of linking to them outside of this forum. This allows us to zoom in on the image when clicked, and also having improved privacy from third-party sources.

Taking Screenshots

  • Microsoft Windows: Take screenshots using the “Windows Snipping Tool”, by pressing either PrtSc or WinShiftS keys on your keyboard.
  • MacOS: Take screenshots by pressing CommandShift4 keys on your keyboard.

Uploading Attachments

  • Drag image files directly into the rich-text editor, or
  • Click on the upload button in the editor toolbar to select files:

3. Properly-formatted Output Bundles from a Scenario Run

Please provide the input/output bundles of each of the relevant modules by running the scenario, or get the bundles from a previous run from the Scenario “History” tab.

Providing the bundles from a scenario run will allow others to replicate what is going on, especially if there are complex data structures (nested arrays and collections) and external services. This helps mapping the correct raw variable names from collections (instead of the label/display name).

Need help❓View instructions ◀

Click on the white speech bubbles on the top-right of each module and select “Download output (or input) bundles”.

A. Upload a Text File

Save each bundle contents in a plain text editor as a moduleNumber-output.txt file. Open the file to check if it has not added additional formatting or encoded the plain text.

  • You can upload files and images to this forum by clicking on the upload button:

    Uploading an attachment here will look like this:
    module1-input.txt (1.2 KB)
    module1-output.txt (3.4 KB)

B. Insert a Formatted Code Block

If you are unable to upload files on this forum, alternatively you can paste the bundles AND format them correctly.

:warning: Formatting IS Important! :warning:

Here are some ways to provide text content in a way that it won’t be modified by the forum.

  • Method 1: Type code fence manually —
    Manually type three backticks ``` in a separate line before and after the content, like this,

    ```
    text goes here
    ```
    
  • Method 2: Highlight the pasted content, then click the preformatted text/code button —

  • Method 3: Upload your file elsewhere and share the public link —
    This method is only advised for large files exceeding the forum upload limit.

Sharing these details will make it easier for others to assist you, so that you can get better answers, faster.

Hope this helps! If you are still having trouble, please provide more details.

— @samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!