How to match users in array?

Hi ! Just started to use N8N :slight_smile:

I got a software that sends me a JSON when a task is created. I want to create that task in ClickUp. I’m trying to assign the task in Clickup to the same user (based on the same email). To do that in ClickUp, I need to assign to an id.

I can get a list of users on Clickup by doing an HTTP request. That gives me an array of users with ids and email. How would I take the JSON I’m getting from my software, check the email of the original user, iterate through the array of ClickUp users and match the id of the user with the same email ?

Ex : From the original task in my software, the task is assigned to [email protected]. How would I assign it to the ID 48857601 in ClickUp ?

Here’s what I’m getting from Clickup when requesting the list of users :

[{
	"teams": [{
			"id": "14216540",
			"name": "Workspace Personal",
			"color": "#40BC86",
			"avatar": null,
			"members": [{
				"user": {
					"id": 26327539,
					"username": "Name0",
					"email": "[email protected]",
					"color": "#0ab4ff",
					"initials": "MB",
					"role": 1,
					"custom_role": null,
					"last_active": "1657890040631",
					"date_joined": "1642098015993",
					"date_invited": "1642098015993"
				}
			}]
		},
		{
			"id": "36753979",
			"name": "Worspace Work",
			"color": "#0ab4ff",
			"members": [{
					"user": {
						"id": 48857601,
						"username": "Name 1",
						"email": "[email protected]",
						"color": "#e040fb",
						"profilePicture": null,
						"initials": "FB",
						"role": 3,
						"custom_role": null,
						"last_active": "1657830387042",
						"date_joined": "1654699163413",
						"date_invited": "1654019475595"
					},
					"invited_by": {
						"id": 26327539,
						"username": "Name2",
						"color": "#0ab4ff",
						"email": "[email protected]",
						"initials": "MB"
					}
				},
				{
					"user": {
						"id": 48857576,
						"username": "Name2",
						"email": "[email protected]",
						"color": "#e65100",
						"profilePicture": null,
						"initials": "SB",
						"role": 3,
						"custom_role": null,
						"last_active": "1654863883603",
						"date_joined": "1654018643777",
						"date_invited": "1654018433880"
					},
					"invited_by": {
						"id": 26327539,
						"username": "Name3",
						"color": "#0ab4ff",
						"email": "[email protected]",
						"initials": "MB"
					}
				},
				{
					"user": {
						"id": 48857577,
						"username": "Name3",
						"email": "[email protected]",
						"color": "#02bcd4",
						"profilePicture": null,
						"initials": "GR",
						"role": 3,
						"custom_role": null,
						"last_active": "1657812443927",
						"date_joined": "1654112738454",
						"date_invited": "1654018433796"
					}
				}
			]
		}
	]
}]

Perhaps something like this could help?

Basically you merge your other task email with a unique list from your clickup users response. Then you’ll have a user property that you can get the id of if they match.

4 Likes

I replaced the 3 list items with 1 javascript function. The merge items was the missing part. Worked perfectly. Thanks a lot ! :smiley:

I actually used “Keep Key Matches” on the merge node. All users as input 1, the email coming from the other app as input 2. It matches and returns the all the info about the user including ID I needed :slight_smile:

3 Likes