Select to view content in your preferred language

Create advanced AGOL view with expression field (no joins)?

277
2
3 weeks ago
Bud
by
Legendary Contributor

Summary:

  1. Admin REST API > view's sublayer > Add To Definition
  2. Added an expression field via JSON
  3. It ran without errors, but I don't see the new field in the view.

 

Detailed Steps:

I've created a AGOL view called test_layer_view on a hosted feature layer:

Bud_0-1777925565968.png

In the view, using the Admin REST API, I want to add a expression field as a test, calculating 1+1.

I'm not using the view's top-level feature layer...

Bud_1-1777925750580.png


...Instead, I'm using the sublayer:

Bud_2-1777925813867.png

Bud_3-1777925989310.png

(Let me know if I'm using the wrong item. Although I tested with the top-level feature layer view, and had the same issue with it.)

 

I got some sample JSON from the ArcGIS REST APIs > Add to Definition (Feature Service) documentation:

(Those docs are pretty complicated and geared towards joins, so I'm not sure how to boil the sample JSON down to just a simple expression field without a join.)

{
"sourceLayerFields": [
  {
    "name": "test_expression_field",
    "alias": "test_expression_field",
    "expression": "1+1",
    "type": "esriFieldTypeInteger"
  }
]
}



I hit the "Add To Layer Definition" button and it ran without errors:

Bud_4-1777926103950.png

Bud_5-1777926148258.png


But when I refresh the view's Data > Fields tab (or the Table tab), the expression field is missing.

Bud_6-1777926313848.png

Likewise, the expression field is missing from the sublayer's JSON definition.


What am I doing wrong?

 

0 Kudos
2 Replies
abdhassa24
Emerging Contributor

Hey Bud, expressions are limited to joined views. I don't think it will work with regular view layers. 

@KhaledHassen can confirm?

Bud
by
Legendary Contributor

Idea: Expression field in advanced AGOL view without join

It's still unclear if this is supported or not. If it's not supported, it would help if the docs could explain this.

Edit:

Esri Case #04171628 - ArcGIS Online Admin REST API - Are expression fields in advanced views without joins supported?

That workflow is not supported, unfortunately. Expressions can only exist on the parent layer for advanced views which have relatedTable objects within the JSON payload. That approach works for standard fields (not expression fields) but advanced views are read-only and so you could not manually calculate the field after it has been added.

0 Kudos