Adding an item to a Pipedrive array without overwriting the original values

Hello everyone,

I’m facing a challenge with my Pipedrive integration.

I’m using the Update a Person module to handle new leads, but I’ve run into an issue with the Phone field. Since this field is an array of objects, sending a new number from my source module causes Pipedrive to overwrite the entire array, deleting all previously existing phone numbers.

I’m looking for a way to append a new number to the existing phone array, ensuring that the old numbers are preserved. Ideally, the solution would also include a check to avoid adding a duplicate number.

I’ve tried using a combination of Make’s array functions, like map, merge, and deduplicate on the phone field, but I’m not sure if that’s the right solution. I also attempted to use an Iterator and an Array Aggregator, but I’m having trouble getting them to work correctly.

I haven’t been able to find a clear method for this in the documentation. Any guidance or examples on how to handle this array merging would be greatly appreciated.

I have 2 ways to access the phone data:

Welcome to the Make community!

:up_arrow: This method most closely resembles the structure/fields in your first screenshot— an ARRAY of COLLECTIONS.

To update the array without overriding it, you first need to create a new collection with the same structure, then “add” it into the existing array.

The easiest way to do this, would be to use the JSON “Parse JSON” module:

{ "new_item": {
  "label": "other",
  "value": "1234567890",
  "primary": false
}}

Then, in the Phones field, toggle the “Map” button. This will allow you to map the existing phones array into that field.

Finally, you can use the built-in function:

  • add
    add(array; value1; value2; ...)

Here’s an example of how you can use this function:

{{ add(1.phones; 2.new_item) }}

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Getting Started

Help Centre Basics

Articles & Videos

Useful to Know

Hope this helps! Let me know if there are any further questions or issues.

@samliew

2 Likes

This solved my problem, thank you @samliew, it was very helpful!

2 Likes