Can a hosted feature layer view exclude related tables

3309
29
Jump to solution
01-19-2018 01:28 PM
Trippetoe
Occasional Contributor III

Hello.

We have a private hosted feature layer that has 3 related tables.  We want to make some of the 'spatial' data available to the public, but we don't want any of the related data visible to the public.

Is there a way to create a hosted feature layer view that excludes the related tables?  I tried not including the join field in the list of fields for the view, but related tables and their data are still present in the view.

thank you

0 Kudos
1 Solution

Accepted Solutions
Trippetoe
Occasional Contributor III

As a quick update, after some additional investigation, Esri staff has confirmed that using the 'deleteFromDefinition' method does not successfully remove related tables from a hosted feature layer view.  They are working on debugging the problem and hopefully a worked around until the bug is fixed.

View solution in original post

29 Replies
KhaledHassen
Esri Contributor

Yes you can exclude the related tables from the view and this has nothing to do with the join field. The UX clones the source and create a view with all layers. But you can drop the related table by using the deleteFromDefinition API on the feature service view.

Admin API can only be used by the admin or the owner of the feature service view.

http://serviceUrl/rest/admin/services/myViewName/FeatureServer/deleteFromDefinition 

You can pass the following json:

{"layers" : [

  {

     "id" : <relatedTableId1>

  },

  {

     "id" : <relatedTableId2>

  } ]

}

Pl. let us know if you have any issue with the above.

Khaled

Trippetoe
Occasional Contributor III

In the source\origin layer definition do i need to drop the 'relationships' element?

0 Kudos
KhaledHassen
Esri Contributor

No. Nothing needs to be done in the source. You just need to drop the related tables from the view and this would remove the relationships from the view also.

Pl. note deleting these layers from the source would delete the related tables permanently and also this would delete all the source data.

Khaled

0 Kudos
Trippetoe
Occasional Contributor III

I think i confused the issues. I apologize for that. 

Within my view, the 'main' layer, id=0, has a json element named 'relationships' which references the 3 related tables that i want to drop from the view.  Do i need to remove that element (relationships) from the view definition as well?

{
"layers" : [

"id" : 0
...
"relationships" : [
{
"id" : 0,
"name" : "",
"relatedTableId" : 3,
},
{
"id" : 1,
"name" : "",
"relatedTableId" : 2,
},
{
"id" : 2,
"name" : "",
"relatedTableId" : 1,
}
],
...
}

0 Kudos
KhaledHassen
Esri Contributor

No. Deleting the related table should take care of deleting the relationships between that table and the view layer. Once you delete all related tables in the view, you should see no relationships in the view layer.

Trippetoe
Occasional Contributor III

It turns out that the 'relationships' element is not removed from the view layer json.  I discovered this because our maps which use the hosted feature layer of the view started reporting an error about missing table id=3.  And "3" was the id of one of the related tables. When i went back to review the hosted feature services json, this is still there:

"layers" : [
{
...
"id" : 0,
...
"relationships" : [
{
"id" : 0,
"name" : "",
"relatedTableId" : 3,
...
},
{
"id" : 1,
"name" : "",
"relatedTableId" : 2,
...
},
{
"id" : 2,
"name" : "",
"relatedTableId" : 1,
...
}
]
}

There is also a relationships element in the json of the hosted feature service's layer, i.e. <servicename>/0

How can i remove the relationships element from the service definition?

thank you

0 Kudos
MingHome
New Contributor III

Hi Hassen,

I read your replays to this post and "add related table" post using "addToDefinition". Can the same rest api be used to remove(hide) feature layers and/or tables in a AGOL hosted feature layer? I have a feature layer service containing many layers and relation tables. I created layer views for deferent maps or apps that only uses a few layers and table in that feature layer service. 

 

Thanks,

Ming 

0 Kudos
KhaledHassen
Esri Contributor

We do not support deleting the relationships directly. We are supposed to delete the relationships when deleting the layer. What is the status of the view service now. Have been able to delete all tables you do not need in the view? Is it possible you have an order issue when deleting. You are supposed to delete the destination table that is not a source of a relationship first.

Trippetoe
Occasional Contributor III

I have deleted all the related tables that i do not need in the view. I deleted the 3 related tables from the view first. 

I can make the view available to you if you'd like to look at it. 

Since it's a view, i can also start all over just to make sure that i followed the correct procedure.

Let me know what you'd like me to try, or if there is any additional information you'd like.  I can also re-open the support ticket i had opened for this question as well.

0 Kudos