Calculated Value

580
6
Jump to solution
03-31-2023 02:58 PM
Labels (1)
DonSjoboen
New Contributor III

Hello,

I'm trying to add an attribute [FACILITYID] from another feature in my web map form.

DonSjoboen_0-1680299306707.png

I have added a form field for this (see above) and have created a calculated arcade expression that seems to work. 

DonSjoboen_1-1680299389121.png

However, when I test this expression by creating a new point (hosted feature layer), the field just shows [object Object] and not the desired value from the other feature layer.

DonSjoboen_2-1680299483695.png

Hoping someone can help with this?

@XanderBakker 

0 Kudos
1 Solution

Accepted Solutions
DonSjoboen
New Contributor III

I ended up solving the issue I was having.  When creating the AGO hosted feature layer, I ended up setting the Facility ID field to be not editable.  Even though I could control the editing permissions of the form itself, because I still had the field in the table set to not edit, that prevented the form calculation from happening.

 

View solution in original post

0 Kudos
6 Replies
ClayDonaldsonSWCA
Occasional Contributor II

that's because you are returning an entire feature (i.e row) not a specific value in that row.

try changing:

return InspectCB to

return InspectCB['FACILITYID']

For the sake of learning - I would add: console(InspectCB) to line 4

then you can view the results in the console tab and see what it is doing

0 Kudos
DonSjoboen
New Contributor III

Thanks, but I have tried that and I get this error...

DonSjoboen_0-1680301638035.png

 

I've also used Console() and it too gave me nothing in the console menu.  Just Null in the output.

I'm using a blank hosted feature layer to add new inspections on existing catch basins feature layer.  I have editing disabled for that field I want to populate too.  Wonder if there isn't something else going on.

I'm using the first example from this blog as a starting point...
https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/common-calculated-expressions-fo...

0 Kudos
ChristopherCounsell
MVP Regular Contributor

From the example you have provided you are missing an ! in the if statement.

This means that it will equate to 'if empty is true, return the empty value'.

By adding the '!' it equated to if this is NOT empty, return true (and then the value)

if (!IsEmpty(region)) {
    return region['name']
} else {
    return null
}
0 Kudos
DonSjoboen
New Contributor III

When I add the !, I don't get [object Object], but I do get an error stating the calculation failed.

So, there is something else going on that is causing this to fail.

0 Kudos
DonSjoboen
New Contributor III
Using the updated line of code (below)... I get the following error message;
DonSjoboen_0-1680547802130.png

 

 DonSjoboen_1-1680547833123.png

 

var OtherCB = FeatureSetByName($map, "Other Govt and City Owned Catch Basins", ['FACILITYID'], true)

var CBinspected = Intersects($feature, OtherCB)
Console(CBinspected)

if (!IsEmpty(CBinspected)) {
    return CBinspected['FACILITYID']
} else {
    return null
}
 
The idea is to write the facility id of an existing catch basin to the new inspection on that catch basin (i.e., hosted feature layer) using a calculated expr in a form in the web map.  I'm wondering if I need to (somehow) add the GlobalID of the hosted feature layer in my expression?  Or if there's something else at play here?
 
Hoping someone has experience with adding an attribute value from one feature to another when adding a new point in a web map/app.
0 Kudos
DonSjoboen
New Contributor III

I ended up solving the issue I was having.  When creating the AGO hosted feature layer, I ended up setting the Facility ID field to be not editable.  Even though I could control the editing permissions of the form itself, because I still had the field in the table set to not edit, that prevented the form calculation from happening.

 

0 Kudos