|
POST
|
I'm not having any problem with dragging and dropping screenshots.
... View more
02-24-2026
07:00 AM
|
0
|
1
|
825
|
|
POST
|
This will involve a couple of steps. This code uses an Arcade element in the popup. First , the code gets all the related records for a feature with the FeatureSetByRelationshipName function (line 1). Next, it creates an array that will contain all the output strings, starting with the area code (line 2). Then it get the First record (Line 4) of the results of a GroupBy function which gets the sum of all the num_trees values (line 5) and then get the Count attribute from that feature (line 10). This value is added to the output array (line 12). It creates another FeatureSet (line 14) that consist of the unique combinations of Tree Role and Status (line 16), with the sum of the Num_Trees (line 17) as an added field. It then gets the unique roles from that FeatureSet (line 20) and loops through them (line 22). In each loop, it get the records for that role with the Filter function (line 24) and loops through those records (line 27), adding up the number of trees for each status (line 28) and creating a string containing status and number of trees (line 29). Finally, it adds a string with the information about each status for the role to the output array (line 31). The return uses the Concatenation function to put each of output strings on a separate line var fs = FeatureSetByRelationshipName($feature, 'your relationship name', ['*'], false)
var output = [`Area: ${$feature.code}`]
var total_Count = First(
GroupBy(
fs,
"code",
{ name: "Count", expression: "num_trees", statistic: "Sum" }
)
).Count;
Push(output, `Trees total: ${total_Count}`)
var grouped = GroupBy(
fs,
["Tree_Role", "Tree_Status"],
[{ name: "Count", expression: "Num_Trees", statistic: "Sum" }]
);
var trees = Distinct(grouped, "Tree_Role");
for (var tree of trees) {
var tree_role = tree.Tree_role;
var filtered = Filter(grouped, "Tree_Role = @Tree_role");
var role_Count = 0;
var output_roles = []
for (var role in filtered) {
role_Count += role.Count
Push(output_roles, `${role.Count} ${role.Tree_Status}`)
}
Push(output, `There are ${role_Count} ${tree_role} trees (${Concatenate(output_roles, ", ")})`)
}
return {
type: 'Text',
text: Concatenate(output, "<br/>")
} This output of this code looks like this:
... View more
02-20-2026
10:53 AM
|
2
|
0
|
196
|
|
POST
|
If this did answer your question, don't forget to click the "Accept as Solution" button. That will help others in research similar questions. And help me maintain my MVP status 🙂 The best place to start would be the Home page of the Arcade documentation, focusing on the Language features section. I would also take a look at some of the Arcade blogs that Esri has written, such with this one, which focuses on scripting for popup. I would also look at some of the posts that @jcarlson has written, since he has scripted some pretty nifty solutions to various problems.
... View more
02-19-2026
06:05 AM
|
0
|
0
|
275
|
|
POST
|
I don't think that's possible with single GroupBy, but I'd love to be proved wrong. You'll have to do two GroupBys, one for each field. That will give you the count for each of the fields. Then you can combine them into a single table with the counts of both and their sums Unfortunately, the GroupBy does strip the domain information from your result. But you can add that back in when combining the tables by looping through all of the domain codes. This code loops through all the domain codes (and this assumes you're using the same domain for both fields) and filters the grouped tables to get their counts. var fs = FeatureSetByPortalItem(Portal("your portal"), itemID, 0, ["*"], false);
var primaryField = "Comment_Type";
var primary = GroupBy(
fs,
[primaryField],
[{ name: "Primary Count", expression: primaryField, statistic: "Count" }]
);
var secondaryField = "Secondary_Type";
var secondary = GroupBy(
fs,
[secondaryField],
[{ name: "Secondary Count", expression: secondaryField, statistic: "Count" }]
);
var theDomain = Domain(fs, primaryField).codedValues;
//return theDomain;
var features = [];
for (var dom of theDomain) {
var code = dom.code;
var filterPrime = Filter(primary, "Comment_Type = @code");
var filterSecondary = Filter(secondary, "Secondary_Type = @code");
var primaryCount = iif(
Count(filterPrime) > 0,
First(filterPrime)["Primary Count"],
0
);
var secondaryCount = iif(
Count(filterSecondary) > 0,
First(filterSecondary)["Secondary Count"],
0
);
Push(
features,
{
attributes:
{
Comment: dom.name,
Primary: primaryCount,
Secondary: secondaryCount,
Total: primaryCount + secondaryCount
}
}
);
}
FeatureSet(
{
fields: [
{ name: "Comment", type: "esriFieldTypeString" },
{ name: "Primary", type: "esriFieldTypeInteger" },
{ name: "Secondary", type: "esriFieldTypeInteger" },
{ name: "Total", type: "esriFieldTypeInteger" }
],
features: features
}
); This code worked properly for my test data and I hopefully didn't get anything wrong when substituting in your fields.
... View more
02-12-2026
01:44 PM
|
1
|
2
|
312
|
|
POST
|
Great! I was just going to reply with a similar solution, which doesn't use the Expects. I included that since sometimes Arcade doesn't fetch all the fields for a feature, but apparently it doesn't need it here. It also uses a for..of loop for the Schema's field array and an output array, which is concatenated in the return var fields = Schema($feature).fields;
var fieldList = [
"Campgrounds_Present",
"DockPier_Present",
"DrinkingWater",
"GrillsPresent",
"HotShowers",
"PicnicTables_Present",
"Restroom_Present",
"Marina_Present",
"PlayEquipment_Present",
"PlayfieldsCourts_Present",
"RV_DumpStation",
"SwimmingPresent",
"TrailsHiking_Present"
];
var output = [];
for (var attribute in $feature) {
if (DomainName($feature, attribute) == "Yes") {
for (var field of fields) {
if (field.name == attribute && Includes(fieldList, field.name)) {
Push(output, field.alias);
}
}
}
}
return {
type: "text",
text: Concatenate(output, "<br>")
};
... View more
02-12-2026
12:17 PM
|
1
|
0
|
394
|
|
POST
|
The Expects function doesn't return anything, so you use it like in Line 1. You don't need to call the entire dataset, since the Schema function can work with $feature. You can also get the fields directly from the Schema in Line 2 (I've learned a few things since writing the code in that previous thread) Expects($feature,'Campgrounds_Present','DockPier_Present','DrinkingWater','GrillsPresent','HotShowers','PicnicTables_Present','Restroom_Present');
var aArray = Schema($feature).fields;
... View more
02-12-2026
10:49 AM
|
0
|
0
|
402
|
|
POST
|
One workaround is to go to your profile page, which lists all the Ideas you've submitted
... View more
02-12-2026
07:37 AM
|
1
|
1
|
394
|
|
POST
|
First, you should put the Expects function as the first line of the script Expects($feature, 'Campgrounds_Present', 'DockPier_Present', 'DrinkingWater', 'GrillsPresent', 'HotShowers', 'PicnicTables_Present', 'Restroom_Present'); Also, if the fields are controlled by a domain, you'll have to use the actual domain code in line 13 or this syntax if (DomainName($feature, i) == "Yes") {
... View more
02-12-2026
07:04 AM
|
0
|
0
|
417
|
|
POST
|
You're loading the FeatureSets without their geometry. Use this syntax instead (removing the "false" at the end) FeaturesetByPortalItem(p, "c756ab8f4b654789812c1b9d6d783640", 31, ["*"]),
... View more
02-06-2026
12:13 PM
|
0
|
0
|
495
|
|
POST
|
In Arcade, you can check whether a field is empty before adding it to the string. This example uses an array (fields) that contains the field name of each of your fields (line 2). The code loops through that array (line 4) and adds the value to an array (output) if the field's value is not empty (line 5). It uses the Concatenate function to return a string with all of the non-empty values in the output array on a separate line (line 7) var output = [];
var fields = ["fieldName1", "fieldName2", "fieldName3"];
for (var field of fields) {
if (!IsEmpty($feature[field])) Push(output,$feature[field]);
}
return Concatenate(output, TextFormatting.NewLine);
... View more
02-06-2026
05:56 AM
|
2
|
1
|
242
|
|
POST
|
I'm not seeing that I see it if I include a special character For the labels that are broken, what are the values for ownlab2 and ownlab3?
... View more
02-04-2026
01:07 PM
|
0
|
2
|
220
|
|
POST
|
What else is in the label? If anything in the label contains those special characters, then the formatting tags will break. For example, this code var ownlab1 = $feature.Site;
var other = "This & that";
"<UND>" + Text(ownlab1) + "</UND>\n" + other; results in this label This code fixes it var ownlab1 = $feature.Site;
var other = Replace("This & that", "&", "&");
'<UND>'+Text(ownlab1)+'</UND>\n' + other;
... View more
02-04-2026
10:35 AM
|
0
|
1
|
493
|
|
POST
|
Great! Don't forget to click the "Accept as Solution" button on the reply or replies that helped
... View more
02-04-2026
09:34 AM
|
0
|
0
|
204
|
|
POST
|
What else is in your multi-line string? Do the other elements have the special characters?
... View more
02-04-2026
06:00 AM
|
1
|
0
|
507
|
|
POST
|
I'm creating a help document for the widget that I'm building. I've gotten everything written out in a Word doc that approximates the layout of the standard widget configuration page. However, exporting a Word doc makes for a very messy html file. Is there a template available to match the widget configuration page? If not, what have you done for your custom widget's help?
... View more
02-03-2026
01:18 PM
|
0
|
3
|
435
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Friday | |
| 1 | 4 weeks ago | |
| 1 | 3 weeks ago | |
| 1 | 10-11-2023 06:18 AM | |
| 1 | 03-23-2026 09:23 AM |
| Online Status |
Offline
|
| Date Last Visited |
14 hours ago
|