|
POST
|
why do they use an empty field called "Field" Because calculation rules expect a field to be calculated. A very simple form of a calculation rule would be // calculate field C as sum of fields A and B
var c = $feature.a + $feature.b
return c In this simple form, you don't return a dictionary like in the blog post you linked, but a simple value. In the rule creation window you sspecify the field this value is stored in. The advanced attribute rules enhance this behavior, so that by editing one table, you can do stuff in other tables. The basic behavior stays the same: the rule still wants to know what value to return and in which field to store the returned value. In the blog post, they don't care about calculating attributes for the point, they just want to automatically create a polygon around the point (the inverse of what you are doing). But because the rule expects a return value and a field, they just use an empty field and return the value that is already there. You don't have to create an extra field for that. Just take a field that is already in your polygon FC (you have to be able to edit it, so not things like ObjectID or GlobalID) and return its value. By returning the value that is already stored in the field, you ensure that nothing is actually changed. For eample, my calculation rules for primary keys look something like this: // Calculation rule for a primary key field
// Field: BauwerkID
// Triggers: Insert, Update
// check if the field is empty
if(IsEmpty($feature.BauwerkID)) {
// yes -> return a new value
return NextSequenceValue("SequenceBauwerkID")
}
// no -> return the field's value (change nothing)
return $feature.BauwerkID I need to add a "definition query ", am I on the right track with this approach? //If value of field X is "A" or "B" proceed, else do nothing (Insert or Update).
if($feature.X == "A" || $feature.X == "B") {
// do stuff
}
else {
return $feature.Field // return the value that is already stored in your field. In this case, no point feature will be created.
}
// Personally, I find code easier to read if you do it the other way around:
if($feature.X != "A" && $feature.X != "B") {
return $feature.Field
}
// Do stuff And how can I rewrite "A" to "C" and "B" to "D" at this point? I'm not sure I understand you correctly: You have a polygon feature with X = "A", so you want to create a point feature and then change X to "C"? In this case, your field for the calculation rule would be X. // if field X is not "A" or "B", do nothing
if($feature.X != "A" && $feature.X !="B") {
return $feature.X
}
// else get the new value for X
var new_x = IIF($feature.X == "A", "C", "D") // $feature.X can only be "A" or "B" at this point (else we would have returned above)
// get the centroid
var centroid = ...
// return
return {
"result": new_x,
"edit": ...
}
... View more
06-09-2021
05:51 AM
|
1
|
2
|
2347
|
|
POST
|
Please post the code you already have and tell us what problems you have with it (erro messages etc). To post code: expand the toolbar in the comment box, insert a code sample, chose Javascript as language.
... View more
06-08-2021
02:08 AM
|
1
|
0
|
2499
|
|
POST
|
I fear I don't really understand what you're asking. Here's what I understood: You have a feature class FC with the fields FC.UniqueID and FC.Flag and a table TBL with the field TBL.UniqueID. If you add or edit a feature in FC, you want to set FC.Flag depending on whether FC.UniqueID is in TBL.UniqueID. Correct? This would be a way to do it: // Calculation rule
// Field: Flag
// Triggers: Insert, Update
// load the table
var table = FeatureSetByName($datastore, "DatabaseName.TableOwner.TableName", ["UniqueID"])
// filter table by UniqueID
var uid = $feature.UniqueID
var filtered_table = Filter(table, "UniqueID = @uid")
// return 0 if the feature's UniqueID is not found in the table
if(filtered_table == null || Count(filtered_table) == 0) {
return 0
}
// return 1 if the feature's UniqueID is in the table
return 1
... View more
06-03-2021
06:20 AM
|
1
|
0
|
823
|
|
POST
|
Have you tried checking for null? if(featureLocation == null || Count(featureLocation) == 0) {
// noting found, return null
return null
}
... View more
06-02-2021
11:18 PM
|
0
|
0
|
2383
|
|
POST
|
If you expand the tollbar in the comment box, you can insert code samples: Try this: if(Count(featureLocation) == 0) {
// noting found, return null
return null
}
... View more
06-02-2021
04:28 AM
|
1
|
0
|
2447
|
|
POST
|
Things to try: // expand the date to include time
var current_year = Date(Year(Now()), 0, 1, 0, 0, 0)
// use text instead
var current_year = Text(Date(Year(Now()), 0, 1), "Y-MM-DD")
var sql = "GRID_NUM = @quad AND MMS_Date_Turning >= date @current_year"
// use the YEAR function in SQL:
var current_year = Year(Now())
var sql = "GRID_NUM = @quad AND YEAR(MMS_Date_Turning) >= @current_year"
... View more
06-01-2021
11:34 PM
|
1
|
1
|
1699
|
|
POST
|
Ah, ok. The only other thing I'm aware of (which isn't to say that there aren't others) is the Attribute Assistant: https://solutions.arcgis.com/shared/help/attribute-assistant/ If I remember correctly though, this works only in ArcMap in an active edit session, so it probably won't do for your App.
... View more
05-31-2021
10:21 PM
|
1
|
2
|
3172
|
|
POST
|
It's hard to copy code from screen grabs. In the future, please use the "Insert Code Sample" button in the comment window: Expand the toolbar, then click this button and chose Javascript as language. // The error is in this line
var inputSequenceName = 'ManholeSequence' + Text(matchedZone)
// matchedZone is a feature set, not a field!
// Try this:
var inputSequenceName = 'ManholeSequence' + Text(matchedZone.GRID)
... View more
05-31-2021
04:28 AM
|
1
|
1
|
1675
|
|
POST
|
This sounds like a job for constraint attribute rules. https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/constraint-attribute-rules.htm These won't let the user apply an insert or edit if it returns False, giving a custom error message instead. // constraint rule for a filed that is non-nullable
// Triggers: Insert, Update
if(IsEmpty($feature.NonNullableField)) { return false }
return true // constraint rule for a field that has to be unique
// Triggers: Insert, Update
var new_value = $feature.UniqueField
var new_gid = $feature.GlobalID
var fs = FeatureSetByName($datastore, "Database.DataOwner.FeatureClass", ["GlobalID", "UniqueField"], false)
fs = Filter(fs, "UniqueField = @new_value AND GlobalID <> @new_gid")
if(Count(fs) > 0) { return false }
return true If you want the unique field to be a sequential field, you should use a calculation attribute rule instead: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/calculation-attribute-rules.htm // calculation attribute rule for a sequential field
// Triggers: Insert, Update
// create a database sequence first!
if(IsEmpty($feature.UniqueField)) {
return NextSequenceValue("SequenceOwner.SequenceName")
}
return $feature.UniqueField
... View more
05-31-2021
02:55 AM
|
1
|
4
|
3184
|
|
POST
|
Select the map frames, go to the "Format" tab and browse through the options in the "Arrange" group. What you want is "Distribute horizontally/vertically".
... View more
05-31-2021
02:33 AM
|
2
|
0
|
1674
|
|
POST
|
Towards the end of the script, they set the GlobalID of new features. GlobalID is not editable by the user, so that doesn't work. Try commenting out the lines that say " 'globalID': GUID() ". if (polyline_1_length > polyline_2_length) {
update_features[Count(update_features)] = {
'globalID': line_feature.globalID,
'geometry': polyline_1
};
new_features[Count(new_features)] =
{
// 'globalID': GUID(),
'geometry': polyline_2,
'attributes': pop_keys(line_att, keys)
};
} else {
update_features[Count(update_features)] = {
'globalID': line_feature.globalID,
'geometry': polyline_2
};
new_features[Count(new_features)] =
{
// 'globalID': GUID(),
'geometry': polyline_1,
'attributes': pop_keys(line_att, keys)
};
}
... View more
05-26-2021
01:12 AM
|
0
|
1
|
881
|
|
POST
|
What exactly is not working? Do you get error messages? var planrecs = FeatureSetByName($map,"House_Number_Change - Address Form and Plan Recs")
var FullAddress = $feature.FullAddress
// var filterStatement = 'OIDStr = @OIDstr'
// this won't work, as you haven't declared the variable "OIDstr". The @ syntax takes care of the proper formatting depending on the type of OIDstr (integer, string, etc), but you have to define what OIDstr actually is:
// also, check the spelling: OIDStr vs. OIDstr
var OIDstr = $feature.OIDstr
var filterStatement = 'OIDStr = @OIDstr'
// Related features as a variable
var relatedData = Filter(planrecs, filterStatement)
// Just exit here if there are no related features
if(Count(relatedFeatures) == 0) {
return 'No other records to show'
}
// Build the pop-up string by iterating through all related features
var popupString = ''
for (var f in relatedData){
// popupString += Text(f.AIN, 'no data') + TextFormatting.NewLine + "Path: " + DefaultValue(f.Path, 'no data') + TextFormatting.NewLine
// You're using wrong arguments for Text. I think you want to use DefaultValue?
popupString += DefaultValue(f.AIN, 'no data') + TextFormatting.NewLine + "Path: " + DefaultValue(f.Path, 'no data') + TextFormatting.NewLine
}
return popupString
... View more
05-25-2021
06:37 AM
|
1
|
2
|
3375
|
|
POST
|
.ipynb files can be opened in Jupyter Notebook, which is integrated in ArcGIS Pro. For how to open it, see this link: Notebooks in ArcGIS Pro—ArcGIS Pro | Dokumentation .py files can be opened in any Python IDE or text editor. The Python installation already includes a simple IDE: IDLE.
... View more
05-20-2021
06:23 AM
|
0
|
0
|
882
|
|
POST
|
var index = 0
if($feature["field_1"] > 0) { index += 1 }
if($feature["field_2"] > 0) { index += 1 }
return index
// if the fields can be null:
if(!IsEmpty($feature["field_1"]) && $feature["field_1"] > 0) { index += 1 }
... View more
05-19-2021
10:59 PM
|
3
|
1
|
3433
|
|
POST
|
Can't help you with the survey design, but to round to 0.5: Multiply by 2, round to zero digits, divide by 2 var rounded_x = round(2 * x, 0) / 2
... View more
05-11-2021
05:01 AM
|
0
|
0
|
3575
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM | |
| 1 | 09-18-2023 04:55 AM | |
| 1 | 11-07-2022 11:15 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|