Hi -
I am still new to Arcade. I have created the below script in AGO Map Viewer Forms that joins to a related table with a one to many relationship based upon Project ID, and pulls the Phase IDs into a field in the Projects layer with each ID separated by ", ". The script is working, but it adds a comma and space after the last PHASE ID (which makes sense based on the code), but I would prefer not to have the comma and space at the end. I have tried adding Replace and Right functions to remove them, but haven't been successful. Any recommendations of how to alter the code to remove the comma and space at the end or prevent them from being added?
Thanks!
Leila
var related_table = FeatureSetById($datastore, /* SNP_PHASE */ "0");
var filter_query = "PROJECTID = '" + $feature["PROJECTID"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);
var output = "";
if (related_data_filtered_count > 0) {for (var related_data_row in related_data_filtered) {output += related_data_row.PH_PHASEID + TextFormatting.NewLine;}}
else {output = "No Related Records.";}
return output;