|
POST
|
If I understand how your fields are set up, give this a try: **Edited to fix an error (i.e. "$datapoint[tg]" instead of "$datapoint.tg")** var result = "";
if (!IsEmpty($datapoint.target)) {
var targetArray = Split($datapoint.target, ",")
for (var i in targetArray) {
result += `<br><br><span style="color:#ffffbe"><i>Target: </i></span> ${Trim(targetArray[i])}`;
var tg = iif(i > 0, `target_goal_${i}`, 'target_goal')
if (!IsEmpty($datapoint[tg])) result += `<br><br><span style="color:#ffffbe"><i>Target Goal: </i></span>${$datapoint[tg]}`;
var tv = iif(i > 0, `target_value_${i}`, 'target_value')
if (!IsEmpty($datapoint[tv])) result += `<br><br><span style="color:#ffffbe"><i>Target Value: </i></span>${$datapoint[tv]}`;
var gv = iif(i > 0, `gap_value_${i}`, 'gap_value')
if (!IsEmpty($datapoint[gv])) result += `<br><br><span style="color:#ffffbe"><i>Gap Value: </i></span>${$datapoint[gv]}`;
var gp = iif(i > 0, `gap_percent_${i}`, 'gap_percent')
if (!IsEmpty($datapoint[gp])) result += `<br><br><span style="color:#ffffbe"><i>Gap Percent (rounded to the nearest whole number) </i></span>${$datapoint[gp]}`;
}
}
return {
textColor: '',
backgroundColor: '',
separatorColor:'',
selectionColor: '',
selectionTextColor: '',
attributes: {
result
}
}
... View more
06-05-2024
08:49 AM
|
1
|
4
|
2991
|
|
POST
|
You can use the Split function to separate out the comma-separated values into an array and loop through that array to get the list of targets. This will also work if there is just one target. var result = "";
if (!IsEmpty($datapoint.target)) {
var targetArray = Split($datapoint.target, ",")
for (var i in targetArray) {
result += `<br><br><span style="color:#ffffbe"><i>Target: </i></span> ${Trim(targetArray[i])}`;
}
}
... View more
06-05-2024
07:40 AM
|
1
|
1
|
3009
|
|
POST
|
Unfortunately, AGOL does not recognize the formatting tags used in ArcGIS Pro. If this for a popup, you can use an Arcade element with html tags like this var output = `This is <span style="color:red">red</span> text`
return {
type : 'text',
text : output
} which gives you a popup like this
... View more
06-04-2024
07:45 AM
|
1
|
0
|
1173
|
|
POST
|
Can you just replace the underscore before you add it to the dictionary? for(var i in split_array) {
var newSplit = Replace(split_array[i], '_', ' ');
Push(choicesDict.features, {"attributes":{
"globalid": globalid,
"Name": Name,
"Jurisdiction": Jurisdiction,
"Community": Sub_Jurisdiction,
"core_capability": core_capability,
"Target": Target,
"split": Trim(newSplit)}})
}
... View more
06-03-2024
08:29 AM
|
1
|
1
|
1795
|
|
POST
|
The DateAdd function expects the input date first, then the value to be added, then the units. The units have to be spelled out ("months" instead of "m"). This code checks if there is a date in the SurveyDay field, then adds the proper number of months. if (!IsEmpty($feature.SurveyDay)) DateAdd($feature.SurveyDay, $feature.Reinspection_Period, 'months')
... View more
06-03-2024
06:49 AM
|
0
|
0
|
1361
|
|
POST
|
You can use this expression. First it checks if there are five trailing zeros, then it checks if there are four. Replace(Replace($feature.ID, '00000', ''), '0000', '');
... View more
06-03-2024
06:16 AM
|
0
|
0
|
1405
|
|
POST
|
Make sure you're getting features from the FeatureSet to get your attributes. Something like this: var pFS = yourParcelFeatureSet;
var intersectedFS = Intersects(pFS, $feature);
var feat = First(intersectedFS); //assuming there is just one feature in the interection results
var owner = feat.OwnerAddress;
var filteredFS = Filter(pFS, 'OwnerAddress = @owner');
var output = [];
for (var f in filteredFS) {
Push(output, ` ${f.ParcelID}
`);
}
//this works for a Text element. Use <br> for an Arcade element
return `${Count(filteredFS)} parcels:
${Concatenate(output, '')}`
... View more
05-30-2024
09:37 AM
|
1
|
0
|
2925
|
|
POST
|
There have been reports that the FeatureSetByRelationshipName function is buggy in Field Maps. The suggested workaround is to use FeatureSetByName and Filter the records using the key to get the related records.
... View more
05-30-2024
08:11 AM
|
1
|
0
|
3472
|
|
POST
|
When searching for members, are they turning on the "Search all ArcGIS Online organization members" and turning off the "Collaboration coordinators only" options?
... View more
05-30-2024
06:50 AM
|
0
|
0
|
2716
|
|
POST
|
A Data Expression needs to return a FeatureSet, not a variable. Replace line 11 with this var theDict = {
'fields': [{ 'name': 'result', 'type': 'esriFieldTypeInteger'}],
'geometryType': '',
'features': [
{
'attributes': {
'result': Text(Round(fiber_total),'#,####')
}
}
]
};
return FeatureSet(theDict);
... View more
05-23-2024
09:41 AM
|
0
|
1
|
1485
|
|
POST
|
I'm using the same code and am getting the different colors as expected. Does your field use a Domain? If so, you'll have to get the DomainName to use in the Decode var color = Decode(DomainName($datapoint, 'event_type'),
... View more
05-23-2024
09:28 AM
|
1
|
1
|
3522
|
|
POST
|
You have to set a variable to use with textColor. Also, Decode is a good replacement for if...else statements like this. var color = Decode($datapoint.event_type, 'Incident Activation', '#ADFF8C',
'Discussion-Based Exercise', '#FFC379',
'Operations-Based Exercise', '#71C1FD',
'#FD7F7F')
return {
textColor: color,
backgroundColor: '',
separatorColor:'#adadad',
selectionColor: '#fcfc86',
selectionTextColor: '#fcfc86',
// attributes: {
// attribute1: '',
// attribute2: ''
// }
}
... View more
05-23-2024
08:51 AM
|
2
|
3
|
3568
|
|
POST
|
Make sure you have the correct item ID. When I try to open it, I get the message "The item you requested cannot be found. The item may have been deleted or you may have entered an incorrect URL."
... View more
05-23-2024
06:15 AM
|
0
|
1
|
4129
|
|
POST
|
This will create a FeatureSet that contains the DateDiff calculation for each record. var fs = FeatureSetByPortalItem(
portal,
9437842bc29b54b07993a9b6b3d63c0d1
0,
['*'], //or use the only the fields you want to include
false
);
var s = Schema(fs);
//return s
Push(s.fields, {'name':'CloseTime', 'alias': 'Close Time', 'type': 'esriFieldTypeDouble'})
var temp_dict = {
fields: s['fields'],
geometryType: '',
features: []
}
for (var f in fs) {
console(f)
var attrs = {}
for (var attr in f) {
attrs[attr] = Iif(TypeOf(f[attr]) == 'Date', Number(f[attr]), f[attr])
}
console(attrs)
attrs['CloseTime'] = DateDiff(f.DateWoClosed, f.InitiateDate, 'hours')
Push(
temp_dict['features'],
{attributes: attrs}
)
}
return FeatureSet(Text(temp_dict))
... View more
05-22-2024
12:30 PM
|
0
|
4
|
4136
|
|
POST
|
It's hard to test this on your private data, but one thing I see is in line 16, you're looping through the Schema, not the FeatureSet. Debugging a script can be made easier by using Console messages at certain points to see where the script is crashing and checking in the variables you're using a returning what you're expecting.
... View more
05-22-2024
09:31 AM
|
0
|
0
|
1195
|
| 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 |
Online
|
| Date Last Visited |
4 hours ago
|