|
POST
|
This expression will filter out the records from the current year. The original dataset has 493721 records, with 2550 records for 2025 var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"79461a1ec0974301bde274177c7108bd", //a layer from the Living Atlas to test
0,
["place", "mag", "time"],
false
);
return Filter(fs, `EXTRACT(YEAR from time) = ${Year(Now())}`); //time is the Date field Then, in the Indicator, use the Statistic value type and Count.
... View more
04-14-2025
01:41 PM
|
0
|
2
|
2153
|
|
POST
|
You can insert calculated values into new fields easily. I've just added lines 16, 23, 44, and 56. You also don't need all the null assignment in the registry loop. If they're not assigned, they will be set to null automatically. // Set portal
var portal = Portal("https://arcgis.com/");
// Create featureset from registry (include all fields)
var unfilteredregistry = FeatureSetByPortalItem(portal, '', , ['*'], false);
// Filter registry to only include rows where "Batch_Number" is not null
var registry = Filter(unfilteredregistry, "Batch_Number IS NOT NULL");
// Create featureset from batch submission (include all fields)
var batchsubmission = FeatureSetByPortalItem(portal, '', 0, ['*'], false);
// Initialise empty feature array
var features = [];
var feat;
var batchCount = count(registry);
// Iterate through batch submission
for (var b in batchsubmission) {
feat = {
attributes: {
OBJECTID: b["objectid"],
Batch_Number: b["batch_number"], // <- map lowercase field to consistent name
Batch_Count: batchCount,
Batch_Submission_Date: b["date_of_batch_submission_for_si"],
Site_Assessment_Complete: b["date_of_site_assessment_complet"],
Batch_Review_Priority: b["BatchReviewPriority"],
Registry_Acquisition_St: b["RegistryAcquisitionStart"],
Registry_Acquisition_Co: b["RegistryAcquisitionComplete"],
Batch_Acquirer: b["BatchAcquirer"],
Elapsed_Time: b["RegistryAcquisitionElapsedTim"],
Registry_Acquisition_Status: b["Registry_Acquisition_Status"],
Site_Assessment_Status: b["Site_Assessment_Status"]
}
};
Push(features, feat);
}
// Iterate through registry
for (var r in registry) {
feat = {
attributes: {
OBJECTID: r["OBJECTID"],
Batch_Number: r["Batch_Number"],
Batch_Count: batchCount
}
};
Push(features, feat);
}
// Create structured dictionary for Featureset
var combinedDict = {
fields: [
{ name: "OBJECTID", type: "esriFieldTypeObjectID"},
{ name: "Batch_Number", type: "esriFieldTypeString" },
{ name: "Batch_Count", type: "esriFieldTypeInteger" },
{ name: "Batch_Submission_Date", type: "esriFieldTypeDate" },
{ name: "Site_Assessment_Complete_Date", type: "esriFieldTypeDate" },
{ name: "Batch_Review_Priority", type: "esriFieldTypeString" },
{ name: "Registry_Acquisition_Start", type: "esriFieldTypeDate" },
{ name: "Registry_Acquisition_Complete", type: "esriFieldTypeDate" },
{ name: "Batch_Acquirer", type: "esriFieldTypeString" },
{ name: "Elapsed_Time", type: "esriFieldTypeInteger" },
{ name: "Registry_Acquisition_Status", type: "esriFieldTypeString" },
{ name: "Site_Assessment_Status", type: "esriFieldTypeString" }
],
geometryType: "",
features: features
};
// Return combined feature set
return FeatureSet(combinedDict);
... View more
04-14-2025
10:49 AM
|
1
|
2
|
1257
|
|
POST
|
Can you provide more detail about your data, like a sample of some of the records in it?
... View more
04-10-2025
11:21 AM
|
1
|
1
|
1055
|
|
POST
|
When using '${}' syntax, you have to use a back tick instead of a regular quote. This is called a template literal Push(result, `${type} ---- ${Round(p, 2)}% or ${Round(a, 2)} acres`)
... View more
04-02-2025
07:00 PM
|
1
|
0
|
883
|
|
POST
|
The Point of Interest markers use preset colors, so you'll have a limited choice in colors. You can use the Pins markers under the Vector Symbols to give you more control over color, transparency, etc. If you want that exact pin shape, you can use the Animated shape but turn off the animation.
... View more
03-31-2025
08:07 AM
|
0
|
1
|
1048
|
|
POST
|
Glad to help. Don't forget to click the "Accept as Solution" button on post(s) that answered your question.
... View more
03-28-2025
08:34 AM
|
0
|
0
|
2382
|
|
POST
|
If my response answered your question, please click the "Accept as Solution" button Also, try using the CSS utility classes with Bootstrap's Overflow className="overflow-auto"
... View more
03-28-2025
08:02 AM
|
0
|
0
|
1418
|
|
POST
|
I didn't include all the lines of the code in my reply, only the ones that were changed. You didn't return the dictionary as a FeatureSet at the end of the code. // Return dictionary cast as a feature set
return FeatureSet(joinedDict); One other thing. I forgot to switch the FeatureSet to be Memorized var plots = FeatureSetByPortalItem(portal, "xyz", 0, ["*"], false);
var grades = Memorize(FeatureSetByPortalItem(portal, "xyz", 0, ["*"], false));
... View more
03-28-2025
07:36 AM
|
1
|
2
|
2387
|
|
POST
|
It sounds like you just need to reverse the logic for (var p in plots) {
var tableID = p["UCode"];
var feat = {
attributes:
{
UCode: tableID,
Vineyard_Name: p["Vineyard_Name"],
BlockCode: null,
FinalGrade: null,
SelectedEURs: null,
last_name: null
}
};
for (var g in Filter(grades, "BlockCode = @tableID")) {
feat.attributes.BlockCode = g["BlockCode"];
feat.attributes.FinalGrade = g["FinalGrade"];
feat.attributes.SelectedEURs = g["SelectedEURs"];
feat.attributes.last_name = g["last_name"];
}
Push(features, feat);
}
var joinedDict = {
fields: [
{ name: "UCode", type: "esriFieldTypeString" },
{ name: "Vineyard_Name", type: "esriFieldTypeString" },
{ name: "BlockCode", type: "esriFieldTypeString" },
{ name: "FinalGrade", type: "esriFieldTypeString" },
{ name: "SelectedEURs", type: "esriFieldTypeString" },
{ name: "last_name", type: "esriFieldTypeString" }
],
geometryType: "",
features: features
};
... View more
03-27-2025
12:47 PM
|
0
|
4
|
2408
|
|
POST
|
The first When statement is missing the DefaultValue When(
$feature.status == 'action', 'Action Stage',
$feature.status == 'minor', 'Minor Flood Stage',
$feature.status == 'moderate', 'Moderate Flood Stage',
$feature.status == 'major', 'Major Flood Stage',
'N/A')
... View more
03-27-2025
10:32 AM
|
1
|
1
|
936
|
|
POST
|
When posting code, use the Insert/edit code sample tool instead of attaching it as a text file. Give this script a try. It puts null values for the plot attributes in each feature for the grades layer and only fills them in when there is a matching plots feature. A couple of additional notes about this. This uses the Arcade variable substitution in the Filter function in line 38, which means you don't have to worry about whether a value has quotes or not. Aslo, calling the Filter function many times in a loop is very expensive and will slow your script down. Using @jcarlson's Memorize function will drastically reduce the execution time for the script. In my test script using a plots layer of 36 features and a grades feature of 51 features, this reduced the execution time from about 8 seconds to half a second. function Memorize(fs) {
var temp_dict = {
fields: Schema(fs)["fields"],
geometryType: "",
features: []
};
for (var f in fs) {
var attrs = {};
for (var attr in f) {
attrs[attr] = Iif(TypeOf(f[attr]) == "Date", Number(f[attr]), f[attr]);
}
Push(temp_dict["features"], { attributes: attrs });
}
return FeatureSet(temp_dict);
}
var portal = Portal("https://xyz.maps.arcgis.com/");
var plots = Memorize(FeatureSetByPortalItem(portal, "xyzx", 0, ["*"], false));
var grades = FeatureSetByPortalItem(portal, "xyzx", 0, ["*"], false);
// Create empty features array
var features = [];
// Populate Feature Array
for (var t in grades) {
var tableID = t["BlockCode"];
var feat = {
attributes:
{
BlockCode: tableID,
FinalGrade: t["FinalGrade"],
SelectedEURs: t["SelectedEURs"],
last_name: t["last_name"],
UCode: null,
Vineyard_Name: null
}
};
for (var p in Filter(plots, "UCode = @tableID")) {
feat.attributes.UCode = p["UCode"];
feat.attributes.Vineyard_Name = p["Vineyard_Name"];
}
Push(features, feat);
}
var joinedDict = {
fields: [
{ name: "BlockCode", type: "esriFieldTypeString" },
{ name: "FinalGrade", type: "esriFieldTypeString" },
{ name: "SelectedEURs", type: "esriFieldTypeString" },
{ name: "last_name", type: "esriFieldTypeString" },
{ name: "UCode", type: "esriFieldTypeString" },
{ name: "Vineyard_Name", type: "esriFieldTypeString" }
],
geometryType: "",
features: features
};
// Return dictionary cast as a feature set
return FeatureSet(joinedDict);
... View more
03-27-2025
07:40 AM
|
0
|
6
|
2432
|
|
POST
|
I use a modal window in my widget and it is scrollable. The window uses a component from a third-party library to build this editable table and uses a CSS file to provide its styling. This is the code in the tsx file return (
<Modal
isOpen={modalVisible}
//className="bg-default w-75 d-flex justify-content-between"
className="bg-default w-100 d-flex "
>
<ModalHeader closeIcon={<CloseOutlined />} toggle={toggleModal}>
{title}
</ModalHeader>
<ModalBody className="w-100">
<article className="table-container">
<table>
<thead>
// etc... and this is the css file with the overflow property .table-container {
display: flex;
justify-content: center;
height: 500px;
overflow: scroll;
} resulting in this table with the scrollable content
... View more
03-27-2025
06:31 AM
|
1
|
3
|
1450
|
|
POST
|
Here's one way to do it. This uses a function to return the color, which can be used in multiple columns. This shows how it can be used to change the textColor and the backgroundColor attributes. function setColor(value) {
When(
value < 20, "#dedede",
value < 30, "#C1C1C1",
value < 60, "#D18E8E",
"#f00000"
);
}
return {
cells:
{
//Other cells
"First Choice":
{
displayText: Text($datapoint["First Choice"]),
textColor: setColor($datapoint["First Choice"]),
//backgroundColor: setColor($datapoint["First Choice"]),
textAlign: "right",
iconName: "",
iconAlign: "",
iconColor: "",
iconOutlineColor: ""
},
"Second Choice":
{
displayText: Text($datapoint["Second Choice"]),
textColor: "",
backgroundColor: setColor($datapoint["Second Choice"]),
textAlign: "right",
iconName: "",
iconAlign: "",
iconColor: "",
iconOutlineColor: ""
},
// More cells
}
};
... View more
03-26-2025
06:08 AM
|
0
|
1
|
1358
|
|
POST
|
When asking a question about code, please the code editor instead of a image of the code. You can use the GroupBy function to do this type of summary. You code would look something like this var fs = FeatureSetByPortalItem(Portal("your portal"), "itemId", 0, ["PipeDiameterField", "PipeLengthField"], false);
GroupBy(fs, ["PipeDiameterField"], { name: "Length", expression: "PipeLengthField", statistic: "SUM" })
... View more
03-26-2025
05:38 AM
|
0
|
0
|
1057
|
|
POST
|
I'm not sure why it's not working in your version of ArcGIS Pro. The $layer variable was introduced in Arcade v1.5 and your version uses v1.17. A simple test works correctly in Pro 3.4.2 on my data (returning the FIELD_ID for the first record on any feature with an OBJECTID greater than 10) var row = $feature.OBJECTID
var sql = "OBJECTID = @row"
if (row > 10) sql = "OBJECTID = 1"
return First(Filter($layer, sql)).FIELD_ID In any case, it should work correctly in the popup in your webmap
... View more
03-20-2025
10:50 AM
|
0
|
0
|
1753
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|