You're supplying the FeatureSetById function incorrect parameters, which would look like this:
var features = FeatureSetById($map,'DemoLayerWM_1117', ['*'], true);
It looks likes you should be using the FeatureSetByPortalItem, which looks like this:
var features = FeatureSetByPortalItem(
Portal('https://www.arcgis.com'),
'7b1fb95ab77f40bf8aa09c8b59045449',
0,
['Name', 'Count'],
false
);
If you have set up a relationship between the feature layer and the tables you can use the FeatureSetByRelationshipName function. This allows you to get there related records without having to loop through all the features.
Here's an example of retrieving the related records for a popup.
var rec = First(FeatureSetByRelationshipName($feature, "DCGIS.ITSPE", ['BIDNAME', 'BIDTOTALDUE', 'BIDCOLLECTED', 'BIDBALANCE']));
if (IsEmpty(rec.BIDNAME)) return 'Not a BID';
return `${rec.BIDNAME}
• Total Due: ${Text(rec.BIDTOTALDUE, '$#,###.00')}
• Collected: ${Text(rec.BIDCOLLECTED, '$#,###.00')}
• Balance: ${Text(rec.BIDBALANCE, '$#,###.00')}`
This example is uses a public service, so you can examine how it uses the relationships.