Skip to main content
Question

Javascript code to filter JSON array to a single value - Troubleshooting help

  • September 25, 2024
  • 2 replies
  • 31 views

I’m having trouble using this Includes code to filter an array of Zoom Meetings by the Zoom meeting topic in a Code by Zapier step. I’m using a Input Data variable Set for the Zoom Array below and the FilterBy variable for the Zoom meeting topic. 

let Set = inputData.Set.split(","); // creates array by splitting Input Data Variable at commas

let FilterBy = inputData.FilterBy; // value to filter the array by

Set = Set.filter(i => i.includes(FilterBy)); // INCLUDE values in array

output = [{Set}];

I’ve also tried this Javascript:

// Input Data Variables from Zapier const meetings = JSON.parse(inputData.meetings); // Parse the 'meetings' JSON data const filterBy = inputData.FilterBy; // The topic to filter by // Filter meetings by the specified topic const filteredMeetings = meetings.meetings.filter(meeting => meeting.topic === filterBy); // Return the filtered result return { filteredMeetings: JSON.stringify(filteredMeetings) };

 

Here’s the array:

{"meetings":[{"uuid":"QmfjdPRnT1iPAx0Jgx+BBQ==","id":89233889087,"host_id":":censored:22:a70a31b480:","topic":"WPTI's Business Engagement Learning Lab (BELL)","type":8,"start_time":"2024-06-12T17:00:00Z","duration":150,"timezone":"America/New_York","agenda":"This is the Zoom link for all BELL sessions.","created_at":"2024-02-28T22:16:10Z","join_url":"https://wpti-org.zoom.us/j/89233889087"},{"uuid":"ZiW3r9TcSVuPkuRtgCkWmg==","id":89178616159,"host_id":":censored:22:a70a31b480:","topic":"2025 DYCD Zoom Registration Template","type":2,"start_time":"2024-09-18T03:00:00Z","duration":60,"timezone":"America/New_York","created_at":"2024-09-18T02:04:11Z","join_url":"https://wpti-org.zoom.us/j/89178616159"},{"uuid":"RD7dmjrSQrq+o7Es4Czxsg==","id":84538904667,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T12:00:00Z","duration":120,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-13T20:00:36Z","join_url":"https://wpti-org.zoom.us/j/84538904667?pwd=3BpBtsvOrNVINpwnisocoyy2RUVRAI.1"},{"uuid":"Gw+82S0BTxKSVIJvVMggUg==","id":84350956274,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T12:00:00Z","duration":120,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T02:33:32Z","join_url":"https://wpti-org.zoom.us/j/84350956274?pwd=Cm2X8egwrZ0UK2RbSqybMXolWQwXAD.1"},{"uuid":"Siwl1NsETVqsA2D0KLjvtQ==","id":84508039163,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T20:00:00Z","duration":0,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T06:20:33Z","join_url":"https://wpti-org.zoom.us/j/84508039163"},{"uuid":"N86fG3fLR+yk86sPBWLYcw==","id":88631515049,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T20:00:00Z","duration":0,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T06:33:39Z","join_url":"https://wpti-org.zoom.us/j/88631515049"},{"uuid":"jopE9qEATOCZKeF/ASZyvw==","id":83232327136,"host_id":":censored:22:a70a31b480:","topic":"120.0","type":2,"start_time":"2024-09-23T20:00:00Z","duration":0,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T06:15:45Z","join_url":"https://wpti-org.zoom.us/j/83232327136"},{"uuid":"ZDf9x2mRTD6kR3oO8hOiWA==","id":82059006875,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T20:00:00Z","duration":0,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T06:17:27Z","join_url":"https://wpti-org.zoom.us/j/82059006875"},{"uuid":"7wHANsWETsOf7MfbTRpzmw==","id":88150803243,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T20:00:00Z","duration":0,"timezone":"America/New_York","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T06:52:26Z","join_url":"https://wpti-org.zoom.us/j/88150803243"},{"uuid":"adqCE9ZRStKoWIBxTPDK6Q==","id":87894406540,"host_id":":censored:22:a70a31b480:","topic":"2022-08-09, Westchester Executive Roundtable","type":2,"start_time":"2024-09-23T23:00:00Z","duration":0,"timezone":"America/Los_Angeles","agenda":"Description and more description. Here's some bold","created_at":"2024-09-18T03:56:14Z","join_url":"https://wpti-org.zoom.us/j/87894406540?pwd=vu3V6bsFofLQ5eweWT3DrvqytD7YDR.1"},{"uuid":"Y7A+FK4pTJGAWbO5yLShEg==","id":83497617384,"host_id":":censored:22:a70a31b480:","topic":"Artificial Intelligence in Workforce Development: AI and Its Impact ","type":2,"start_time":"2024-10-17T17:00:00Z","duration":120,"timezone":"America/New_York","agenda":"Target Audience: Front-Line Staff, Supervisors, Program Directors \n\nFacilitators: Justin Collins\nCo-Facilitator: Yanni Deconescu \n\nArtificial Intelligence (AI) \u2013 including Generative AI like ChatGPT \u2013 is rapidly changing the way we work, and by exten","created_at":"2024-09-19T13:18:17Z","join_url":"https://wpti-org.zoom.us/j/83497617384"},{"uuid":"rWsVoHZVSfK7Lktn+WKdcA==","id":88938959676,"host_id":":censored:22:a70a31b480:","topic":"AI Tools for Workforce Development","type":2,"start_time":"2025-01-23T18:00:00Z","duration":120,"timezone":"America/New_York","agenda":"Target audience: Front-Line Staff, Supervisors, Program Directors\n\nFacilitators: Justin Collins\nCo-Facilitator: Yanni Deconescu \n\nTraining Description: Artificial Intelligence (AI) is not only changing the way the world works, it also offers helpful ","created_at":"2024-09-19T13:26:04Z","join_url":"https://wpti-org.zoom.us/j/88938959676"}]}

 

Both sets of code return no meeting with a value. Here’s a sample response. Note that the ID omdG3wEPJPq5XS0997DaekojW0xbon15 is not present in the JSON Request body.

Filtered Meetings

[]

ID

omdG3wEPJPq5XS0997DaekojW0xbon15

runtime_meta

Runtime Meta Memory Used Mb

74

Runtime Meta Duration Ms

88

Runtime Meta Logs

Runtime Meta Async

false

Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30739 replies
  • September 25, 2024

Hi @mountainrog 

Can you post screenshots showing how your full Zap Code step is configured in EDIT mode, so we can see the Input Values and core Code?


  • Author
  • Beginner
  • 2 replies
  • September 25, 2024

@Troy Tessalone Thanks! I’ve resolved this issue. The issue was related to a slight misspelling in the value being searched on.