I'm new to coding so I'm struggling to find any guidance on this. I know how to access data from one layer and show it in a pop-up for another layer, but now I'm trying to merge the multiple pop-ups for one polygon into one pop-up.

We use PolyID as our unique identifier. We have multiples records for the same polygon with different activity types listed. When I select a polygon on the map, I brings up multiple pop-ups, one for each record.

I want all records for each PolyID to be shown in one pop-up ordered by planned year of activity.
Is this possible? If so, what would be the code to accomplish this?