|
POST
|
Your first code snippet won't work properly, but the second one will
... View more
08-30-2024
12:22 PM
|
0
|
2
|
2207
|
|
POST
|
Your code is returning the error message since the first feature in streets doesn't have the correct SID. You will only get the St_Name value back if you click on the first feature. What you should do is return the error message after looping through all the streets. You don't need the extra "else if" var street = FeatureSetByName($datastore, 'tStreet', ['Street_ID','St_Name'],false);
var SID = $feature.St_ID;
for (var i in street)
if (i.Street_ID == SID)
return i.St_Name
return {"errorMessage": "Street ID does not exist"} That said, although you can do this without braces, it might be more intuitive to use braces var street = FeatureSetByName($datastore, 'tStreet', ['Street_ID','St_Name'],false);
var SID = $feature.St_ID;
for (var i in street) {
if (i.Street_ID == SID) {
return i.St_Name
}
}
return {"errorMessage": "Street ID does not exist"}
... View more
08-30-2024
12:16 PM
|
0
|
1
|
2214
|
|
POST
|
Thanks for the response. Unfortunately, changing it to fieldAlias didn't make a difference.
... View more
08-29-2024
01:36 PM
|
0
|
0
|
908
|
|
POST
|
That appears to be working properly when I view the map I'm testing this on in Field Maps. I did notice that your line 21 was missing the code and closing parenthesis. I don't know if that was the issue. I realized that I didn't quite have the alias part right. You'll have to make this update to the fieldTest function. This also returns the fields with domains and the date fields formatted. function fieldTest(fieldList, fieldName, fieldAlias, fieldType) {
if (Includes(fieldList, fieldAlias)) {
if (fieldType == 'esriFieldTypeDate') attributes[fieldalias] = Text($feature[fieldName], 'dddd, MMMM D, Y');
else attributes[fieldalias] = DomainName($feature, fieldName);
Push(fieldInfos, { fieldName: fieldAlias });
}
} The if statements would look like this if (code == 3) fieldTest(["Defect ID", "Defect Type", "Comment", "Critical Area","Area (sqft)", "Height / Depth (in)"], fields[i].name, fields[i].Alias, fields[i].type); Note: during my testing, the app started crashing when opening the popup, so I have to figure out what is happening
... View more
08-29-2024
01:27 PM
|
0
|
0
|
4288
|
|
POST
|
I have a map where I've added an Arcade element to a popup. It works properly when I test in Map Viewer but when I try it in Field Maps, the app crashes and restarts. I've tried looking in the Troubleshooting log, but it only shows the information after the app restarts. In the attached log, I clicked the feature exactly at 4:00 pm and the first log entry is when it restarts several seconds later. How can I determine what is causing the crash? This is the code I'm using var fields = Schema(FeatureSetByPortalItem(Portal('url'), 'item')).fields;
var attributes = {};
var fieldInfos = [];
function fieldTest(fieldList, fieldName, fieldAlias) {
if (Includes(fieldList, fieldAlias)) {
attributes[fieldalias] = $feature[fieldName]
Push(fieldInfos, { fieldName: fieldAlias });
}
}
var code = DomainName($feature,"Survey");
for (var i in fields) {
if (code == "Fish and Benthic") fieldTest(["Site ID","Fish Status","Fish Date","Benthic Status", "Benthic Date"], fields[i].name, fields[i].Alias);
else fieldTest(["Site ID","Fish Status","Fish Date"], fields[i].name, fields[i].alias);
}
return {
type: "fields",
fieldInfos: fieldInfos,
attributes: attributes
};
... View more
08-29-2024
01:25 PM
|
0
|
2
|
921
|
|
POST
|
Glad to help. Don't forget to click the Accept as Solution button on the post that answers your question. If you want the fields in the order that they are in the original popup, then you have to get the schema for the FeatureSet using the FeatureSetByPortalItem function. This appears to be the only way to get them in their original order. If you want them in another custom order, that will take a little more coding. Replace line 1 with this var fields = Schema(FeatureSetByPortalItem(Portal('your portal url'), 'your item number')).fields; To get the alias, change the if statements to include the aliases and use "alias" instead of "name" at the end of the line if (code == 3) fieldTest(["Defect ID", "Defect Type", "Comment", "Critical Area","Area (sqft)", "Height / Depth (in)"], fields[i].alias);
... View more
08-29-2024
10:10 AM
|
0
|
2
|
4304
|
|
POST
|
I can get the fields from a Feature or a FeatureSet using the Schema function and cycling through the fields key var output = []
var fields = Schema(item).fields;
for (var f in fields) {
Push(output, fields[f].name)
}
return {
type : 'text',
text :Concatenate(output, ', ')
} For a Feature, in AGOL, the fields are returned in alphabetical order (with the exception of OBJECTID). In ArcGIS Pro, they are returned in their original order. These two screenshots use the same item from AGOL and the same code in the Arcade element For a FeatureSet, the order of the fields depends on how I get that FeatureSet. If I get it from the map using FeatureSetByName, the fields are returned in alphabetical order. If I get it from the Portal using FeatureSetByPortalItem, they are returned in their original order. Why isn't this consistent?
... View more
08-29-2024
09:51 AM
|
1
|
2
|
1332
|
|
POST
|
Your sql statement is incorrect. You have to use "=" instead if "IS". You need quotes around the values and sql is picky about the type of quotes. Double quotes are used around the entire statement and single quotes are used for the attributes. var sql = "status = 'R' OR status = 'A' OR status = 'C'" You can make this simpler by using IN keyword var sql = 'status IN ('R', 'A', 'C')"
... View more
08-29-2024
07:15 AM
|
0
|
0
|
1097
|
|
POST
|
Here's one way to do it. This uses an Arcade element to return a truncated field list. It first gets the list of fields and loops through them. As it loops through the fields, the if statements sends a different set of fields for each Defect Type to the fieldTest function, which will populate the field list with the field names and their values. Note that if the Defect Type field uses a Domain, you'll have to use the DomainName function to use the descriptive name. var fields = Schema($feature).fields;
var attributes = {};
var fieldInfos = [];
function fieldTest(fieldList, fieldName) {
if (Includes(fieldList, fieldName)) {
attributes[fieldName] = $feature[fieldName];
Push(fieldInfos, { fieldName: fieldName });
}
}
var code = $feature["Defect Type"]; // or DomainName($feature, "Defect Type)
for (var i in fields) {
if (code == "Unevenness") fieldTest(["Area", "Height", "Sunken"], fields[i].name);
else if (code == "Missing") fieldTest(["Area", "Height"], fields[i].name);
//else if for each of other defect conditions
}
return {
type: "fields",
fieldInfos: fieldInfos,
attributes: attributes
};
... View more
08-28-2024
12:36 PM
|
2
|
4
|
4366
|
|
POST
|
Are you following the instructions from documentation page "Refine layers for all devices"? To create a separate layout for a medium- or small-screen device, click the Custom button next to the layout of the page or window. Then you can manually arrange and resize widgets and windows for the selected screen device. To remove a widget or screen group from a small device layout, click the Move to the pending list button on its toolbar. This removes the widget or screen group from the canvas of the current device and saves its configuration in case you need to add it back to the layout. Once you enable the custom layout option, if any other widgets are added to other device modes, they aren't added to the current device. You can manually add them from the Pending tab in the Insert widget panel.
... View more
08-28-2024
10:27 AM
|
0
|
1
|
3157
|
|
POST
|
@EmilyGeo Why does the search option keep the ArcGIS World Geocoding Service even if it's turned off in the web map settings?
... View more
08-22-2024
08:30 AM
|
0
|
0
|
2249
|
|
POST
|
To add the ability to search by layer, open the web map's item page. In the Settings tab, go to the Web Map section and under Application Settings, check the By Layer option. Add the layer you want to search and select its field.
... View more
08-22-2024
08:19 AM
|
3
|
0
|
2261
|
|
POST
|
You have to encase the field name in brackets Left($feature["Control_Number__Control_Account___Control_Account_"], 5) feature
... View more
08-22-2024
06:57 AM
|
3
|
1
|
1137
|
|
POST
|
I'm not sure why it's not working without looking at the data. The sql statement should work properly. That fact that it stopped working recently could mean there was a change to the underlying data, which is why I was asking if the layer is the correct one and if the fields are present in that layer.
... View more
08-21-2024
12:13 PM
|
0
|
1
|
2108
|
|
POST
|
I'm not sure that solved your problem, since it's not returning the filtered data set. That was just to make sure that the dataset that is being returned is the one you're expecting. You still have to figure out why the filter isn't working (line 23) You can start here to learn about the fundamentals of Arcade. You can also view some technical sessions from last year's User Conference. I'm not sure if this year's sessions are available yet.
... View more
08-21-2024
09:27 AM
|
0
|
4
|
5472
|
| 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 |
Thursday
|