Extract a value from multiple Collections and create new Array

Hi there!

I am getting the list of Contacts of a lease and need to construct a new request to do an update. To do this, I need to extract the contact that is defined as being the Primary, and also create a new array of all the contact IDs on the lease.

The source is a GET which returns multiple collections: Open API, powered by Propertyware

The desired output is a PATCH: Open API, powered by Propertyware

There are two things I need some help with:

  1. A new variable named primaryContactID which has the value of the “id” of the primary contact
    "id": 5205819426
	"role": "Primary"
  1. A new variable named tenantIDs which creates an array containing a list of all the contact ids in the format needed:
	"tenantIDs": [
		7336525843,
		7336525842,
		5205819426,
		6315868164
	],

I can then reference these variables when creating the PATCH module

This is probably basic stuff for many, but I’m still struggling with extracting nested info and outputting it in a desired format. Any help would be much appreciated!

get_contacts.json (3.6 KB)
desired_patch.json (373 Bytes)

You can use the built-in functions map and get to access variables within an array.

To do this, you can use the built-in function map

{{ map(complex array; key; [key for filtering]; [possible values for filtering separated by a comma]) }}

and the built-in function get (or first) —

{{ get(object or array; path) }}

so you get something that looks like this —

{{first(map(1.data; "id"; "role"; "Primary"))}}

(copy-paste the above into the field, or type it exactly as shown)

Screenshot 2025-06-29 202345

This is just an example. Your final solution may or may not look like this depending on your requirements and actual data.

For more information, the function’s documentation can be found in the Help Centre and the “Mapping with Arrays” link below. You should also complete the tutorials in the Make Academy, especially Using get() and map() functions.

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

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

@samliew

Hey @samliew, thanks for that! I’m slowly getting more familiar now with the map function.

The follow-on issue is the creation of the PATCH request, and I think I’m having an issue with the tenantIDs.

Here are the variables created using the map function:

I tried using them in the PATCH request like this:

But I get an error 500. Here’s what it looks like when passed to the PATCH module:

{
	"endDate": "2025-05-31",
	"moveInDate": "2021-10-01",
	"primaryContactID": 5205819426,
	"startDate": "2024-05-01",
	"tenantIDs": [
		7336525843, 7336525842, 5205819426, 6315868164
	],
	"unitID": 2761129985,
	"noticeGivenDate": "2025-06-28",
	"reasonForLeaving": "Personal",
	"scheduleMoveOutDate": "2025-07-31",
	"status": "Active - Notice Given"
}

Is there a way to have the tenantIDs variable be created in exactly the format needed - i.e. with the IDs on a separate lines? The goal is to just do this in the PATCH module:

…and to get this request content:

{
	"endDate": "2025-05-31",
	"moveInDate": "2021-10-01",
	"primaryContactID": 5205819426,
	"startDate": "2024-05-01",
	"tenantIDs": [
		7336525843,
		7336525842,
		5205819426,
		6315868164
	],
	"unitID": 2761129985,
	"noticeGivenDate": "2025-06-28",
	"reasonForLeaving": "Personal",
	"scheduleMoveOutDate": "2025-07-31",
	"status": "Active - Notice Given"
}

There is some artefact in the variable created that is throwing an error 500. Using an online JSON Diff tool, I see the red what looks like bullet points in the right screen. The left screen is what works when I put it through Postman.

Any ideas on how to strip this from the result of the tenantIDs variable?