|
POST
|
Your post and screenshots are a little confusing. Do you have only one row in the summary table? If so, you can do it like this: max_date = [row[0] for row in arcpy.da.SearchCursor(BuildCablesMax, ["MAX_DATECREATED"])][0]
arcpy.management.CalculateField(BuildCableLines, "Last_Update_Date", f"'{max_date}'") If your summary table has multiple rows, you should probably use Join Field.
... View more
08-30-2023
11:10 PM
|
1
|
1
|
2053
|
|
POST
|
var txt = $feature.TextField1
if(IsNaN(Number(txt))) { return txt }
var parts = [
Left(txt, 3),
Mid(txt, 3, 3),
Right(txt, 3)
]
return Concatenate(parts, "-")
... View more
08-29-2023
12:27 AM
|
2
|
1
|
2064
|
|
POST
|
Attribute Rules don't work with layers in maps, they work with featureclasses/tables in the same database. Etages has to be in the same database as the fc where you are implementing the rule If the name is different, change it in the expression If you are working in an Enterprise database (.sde), change the name to the full name: DatabaseName.DataOwner.TableName
... View more
08-25-2023
04:43 AM
|
0
|
0
|
4644
|
|
POST
|
For the IDs, see my answer in this question: https://community.esri.com/t5/arcgis-pro-questions/using-attribute-rules-to-create-sequential-id/m-p/1320130 For returning the nearest feature's attributes, you could do something like this: // Calculation Attribute Rule
// field: empty!
// triggers: Insert, update
var other_fc = FeaturesetByName($datastore, "Etages")
var search_dist = 1000
// get all features in other_fc within search distance
var other_near = Intersects(other_fc, Buffer($feature, search_dist))
// find the nearest
var min_dist = search_distance
var other_nearest = null
for(var f in other_near) {
var dist = Distance($feature, f)
if(dist < min_dist) {
other_nearest = f
min_dist = dist
}
}
// abort if no feature was found in the search distance
if(other_nearest == null) { return }
// copy the attributes
return {
attributes: {
EtaID: EtaID,
EtaCode: EtaCode,
NivCode: NivCode,
}
}
... View more
08-25-2023
02:33 AM
|
0
|
2
|
4657
|
|
POST
|
You probably have set UNIT_ID as field for the rule? In that case, it will try to insert a dictionary into that field, which fails. You have to leave the field empty.
... View more
08-24-2023
09:05 AM
|
1
|
2
|
1688
|
|
POST
|
if($feature.RouteType == 'Parental Assistance') {
return $feature.ParentalAllowanceMiles
}
return $feature.RouteOutwardDistance + $feature.RouteInwardDistance https://developers.arcgis.com/arcade/guide/operators/ https://developers.arcgis.com/arcade/guide/logic/
... View more
08-24-2023
06:23 AM
|
2
|
1
|
1055
|
|
POST
|
CreateTable takes two arguments: The output workspace and the output name. Your last parameter is a Table, if you get that as text, it returns the table path. If you use that in CreateTable, it tries to create a table with the complete path as name. This puts illegal characters ("\") into the table name. If you make the last parameter a String, it should work.
... View more
08-24-2023
01:24 AM
|
3
|
1
|
1812
|
|
POST
|
I would like to extract attribute from a table to update attributes of a point feature class Ah. Well, that is not what your original attribute rule does (and so it's also not what my rule does). These rules will do it the other way around: They will update/add a row in the table when you update/add a point in the feature class. No worries, what you want is actually easier: // Calculation Attribute Rule on asset_july_2023
// trigers: Insert, Update
// field: empty
// get the first related row from tbl_asset_info
var key = $feature.Asset_NAME
var asset_infos = FeatureSetByName($datastore, "tbl_asset_info", ["*"], false)
var asset_info = First(Filter(asset_infos, "Asset_NAME = @Key"))
// abort if no related row was found
if(asset_info == null) { return }
// return the related row's attributes
return {
result: {
attributes: {
ASSET_ID: asset_info.ASSET_ID,
TYPE: asset_info.TYPE,
VALUE: asset_info.VALUE,
}
}
} The null check in line 11 will solve your error message.
... View more
08-23-2023
04:25 PM
|
1
|
2
|
3208
|
|
POST
|
The Attribute Rule needs to know which features it has to update. That is why you have to supply the GlobalID or OBJECTID of the features in the update array. Take a look at the documentation of the return dictionary. Some other problems: You're using an outdated method of appending elements to an array (counter++). If you're using ArcGIS Pro 2.7+ / Enterprise 10.9+, you can use Push(). When you don't find related features, you return a string, but the rule has no assigned field. I don't actually know if that will give an error, but it's useless at least, nobody will see that message. Instead of using Count() (slower) and the error message, just do the for loop and return the result. If the update array is empty, nothing will happen. You're using the values that are already in the asset info table, so nothing will change. You have to use the attributes of $feature You're using assTabList for updates and adds. This will update the features in tbl_asset_info and add new ones, giving you duplicates. What you want to do is this: If you're inserting a new features, use adds If you're updating a feature, use updates // Rule for asset_july_2023
// triggers: insert, update
// field: no select
// arrays that store adds and updates to the asset info table
var assAdds= []
var assUpdates = []
// attributes of the $feature
var featureAttributes = {
'ASSET_ID': $feature.ASSET_ID,
'TYPE': $feature.TYPE,
'VALUE': $feature.VALUE
}
// if this is an insert, add a new asset info feature
if($editcontext.editType == "INSERT") {
var newAss = {
'attributes': featureAttributes
}
Push(assAdds, newAss)
}
// if this is an update, edit all related asset info features
if($editcontext.editType == "INSERT") {
// value of shared field
var key = $feature["Asset_NAME"]
// search for related features in tbl_asset_info feature class
var assInfFS = FeatureSetByName($datastore, "tbl_asset_info", ["*"], false)
var assInfFilter = Filter(assInfFS, "Asset_NAME = @Key")
for(var asst in assInFilter) {
var update = {
"globalID": asst.GlobalID,
'attributes': featureAttributes
}
Push(assUpdates, update)
}
}
return {
'edit': [{
'className': 'asset_july_2023',
'adds': assAdds,
'updates': assUpdates
}]
}
... View more
08-23-2023
01:17 AM
|
1
|
4
|
3229
|
|
POST
|
Replace line 25 with this: 'incident_date': Number(f.incident_date), In previous Arcade versions, Date values had to be submitted as Numbers. This problem is fixed in AGOL and will probably be fixed in Enterprise 11.2
... View more
08-22-2023
03:28 PM
|
0
|
1
|
1549
|
|
POST
|
Possible error sources: null values are treated as 0. D=null will return 0, so make sure you actually have values in DebrisDepth. for D<216, your result will be smaller than 1. If your target field is an integer field, these will be rounded down to 0. Make sure that your target field is a double field. Make sure that your StructureType is actually "SD INLET", else the rule will return UntrackedVolume You have a typo: PrereatVol should be PretreatVol
... View more
08-21-2023
11:42 PM
|
0
|
2
|
5250
|
|
POST
|
I can't reproduce the error, but you might want to try these: // your output field is an integer, try rounding
Round(($feature.PassengersOutward + $feature.Passengerslnward) / 2)
// try using the Mean() function
Mean([$feature.PassengersOutward, $feature.Passengerslnward])
// try both
Round(Mean([$feature.PassengersOutward, $feature.Passengerslnward]))
... View more
08-21-2023
08:34 AM
|
0
|
0
|
3535
|
|
POST
|
Sorry, should have made that clearer: You can get both from my original solution, I edited it.
... View more
08-21-2023
08:21 AM
|
1
|
0
|
804
|
|
POST
|
You're trying to edit a raster layer, which you can't do, as it says in the error message and when you hover over the red exclamation mark. In ArcGIS Pro, editing is automatically enabled. If you want to do it manually, you have to change it in the options.
... View more
08-20-2023
09:11 AM
|
0
|
0
|
7928
|
|
POST
|
Template literals in Arcade enclose the value you want to insert into the string with `${value}`. Not to be confused with the leading dollar sign on global variables like $feature, $datastore, $map, etc. function heterotrophs() {
return `${$feature['where_is_it_located_does_this_l']}
${$feature['does_this_location_look_like_it']}
${$feature['note_the_physical_description_s']}
${$feature['note_its_behavior_mode_of_locom']}
${$feature['what_do_you_think_it_might_eat']}`
} If the $ is placed correctly, will the output display the actual answers? Yes, it should display the actual field values for the feature you clicked on. If you also want to display the question/field name, you could take my answer or put the questions into the functions of Ken's answer like so: function heterotrophs() {
return `Where is it located: ${$feature['where_is_it_located_does_this_l']}
Does this location look like it: ${$feature['does_this_location_look_like_it']}
Note the physical description: ${$feature['note_the_physical_description_s']}
Note its behavior mode: ${$feature['note_its_behavior_mode_of_locom']}
What do you think it might eat: ${$feature['what_do_you_think_it_might_eat']}`
}
... View more
08-19-2023
12:12 AM
|
0
|
0
|
3943
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-30-2023 09:57 AM | |
| 1 | 05-18-2023 12:51 AM | |
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|