Filter transformer data based upon a select box

Current Setup
Api gets data
transformer modifies data for table
d = {{getRpCalendar.data.value}}
var outArr = []
d.forEach((a) => {
outArr.push({
id: a.id,
title: a.subject,
start: a.start.dateTime,
end: a.end.dateTime,
details: a.bodyPreview,
categories: a.categories,
location: a.location.displayName,
office: a.location.displayName.split(';').pop()

})
})
return outArr

I want to be able to filter the data based upon a select box.

Hey @nroeder!

It looks like you can use array.filter here. Something like

var filteredArr = outArr.filter(calendarEvent => calendarEvent.title === yourSelectComponent.value)

or, in the case of a multiselect: calendarEvent => ourSelectComponent.value.includes(calendarEvent.title}

Does that seem like it could be what you're looking for? Curious to know exactly what logic you want to use to filter your array.

Yep that worked perfectly, thanks again!

Creating a booking calendar to manage appointments. Instead of creating different calendars for each location and type of work, using one calendar for all and then giving the user the ability to filter by location and/or type.

Any idea on why I'm receiving undefined? it works if I just use start: a.start.datetime

d = {{getRpCalendar.data.value}}
var outArr = []
d.forEach((a) => {
outArr.push({
id: a.id,
title: a.subject,
start: [{
datetime: a.start.datetime,
timezone: a.start.timezone
}],
end: a.end.dateTime,
details: a.bodyPreview,
categories: String(a.categories),
location: a.location.displayName,
office: a.location.displayName.split(';').pop()
})
})

var filteredArr = outArr.filter(calendarEvent => {{ multiselect2.value}}.includes(calendarEvent.location))
return filteredArr

  • id:""
  • title:"Test"
  • :arrow_forward:

start:[] 1 item

  • :arrow_forward:

0:{} 2 keys
* datetime:undefined
* timezone:undefined

  • end:"2022-10-11T20:28:22.6620000"
  • details:""
  • categories:"Adjustment"
  • location:"223"
  • office:"223"

Hmm.. I'm having a bit of trouble reading the query - do you think you could post a screenshot of it? Also, where exactly are you seeing undefined get returned?

I got it, I wasn't capitalizing correctly.

start: [{
dateTime: a.start.dateTime,
timeZone: a.start.timeZone
}],

1 Like