Add ObjectID to Query Layer

1674
2
Jump to solution
12-04-2020 06:06 AM
Labels (4)
tigerwoulds
Occasional Contributor III

I have created some point QueryLayers in ArcMap 1081. The layers are coming from a SQL Server 17 SDE Database. I am trying to figure out whether I can publish this data to our GIS Server as a feature service. Users will need to edit existing point locations and create new ones.


When I go to publish, I get an error about no ObjectID:

TigerWoulds_2-1607090717545.png

 


I can right click the error and select Add Incrementing IDs option which opens the Add Incrementing ID tool. When I run this, I get an error:

TigerWoulds_0-1607090681383.pngTigerWoulds_1-1607090693935.png


If I remove the Create option in the feature service , I can successfully publish. Any ideas how to add an ObjectID field to the query layers?

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

You can't add an OBJECTID field to a query layer, you have to select one of the participating tables' OBJECTIDs.

SELECT t1.OBJECTID, t1.field1, t2.field1 FROM ... AS t1 JOIN ... AS t2 ON ...

 

You should be able to share that as a feature layer. However, I'm pretty sure you won't be able to publish it in a way that users can create new features. For that, you have to publish the original feature classes with write privileges (you can still hide fields).


Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

You can't add an OBJECTID field to a query layer, you have to select one of the participating tables' OBJECTIDs.

SELECT t1.OBJECTID, t1.field1, t2.field1 FROM ... AS t1 JOIN ... AS t2 ON ...

 

You should be able to share that as a feature layer. However, I'm pretty sure you won't be able to publish it in a way that users can create new features. For that, you have to publish the original feature classes with write privileges (you can still hide fields).


Have a great day!
Johannes
0 Kudos
tigerwoulds
Occasional Contributor III

Thanks. I did some testing and found this to be true. 

0 Kudos