2

I am programming for an web editing application with ArcGIS API for JavaScript. I've published a version of ArcSDE with Feature Acces and I need to know how can I change in the web application from this version to another through the user that is connected to the application using the security manager of ArcGIS Server.

I've seen that exist a parameter gdbVersion and SetGDBVersion of featurelayer, but I don't know how to use. I need to see some example of this because the information in the documentation is not enough.

Can anyone help me? Any sample, please? Thanks

  • I think through JSAPI its not possible – Sunil Oct 23 '13 at 11:06
2

i definitely disagree with Sunil's comment above.

take a look at the following sample https://developers.arcgis.com/en/javascript/jssamples/widget_identitymanager_client_side.html

within the storeCredentials function you can see that the username of the person that signed in can be dug out using a statement like this

idObject.credentials[0].userId;
>>>"rick"

you would have to write your own logic to use information like this to determine how to set an appropriate corresponding SDE version on the featureLayer for editing.

| improve this answer | |
  • 2
    The OP asks for "how to change version in JS” but this is answering "how to find the user logged in" totally different questions. The funny thing is that the OP has accepted the answer. So much for community guidelines. – Mahdi Apr 20 '15 at 11:27
3

It is possible! What you need first is a versioned feature class. To be bried, I assume you already know how to create versions and edit them, say using ArcMap or Arcpy. Unfortunately, there is no pre-packaged way to do it in JSAPI (AFAIK in 3.12), however, you can easily create geoprocessing services in Python that will do it though Arcpy and are accessible in JSAPI through georpocessing tasks interface (let me know if you need help with this part).

Now, assuming you have two transactional versions, call them A and B, you usually see them in ArcMap as sde.A and sde.B. By default, your published map has its gdbVersion empty which is basically DEFAULT version. However, as you have found, if you have those versions already setup, you can call myLayer.setGDBVersion('A'); to switch the transactional version and your map should refresh itself automatically. After the first call to setGDBVersion, myLayer.gdbVersion will not be empty and will have the selected version.

Note, to get a list of versions, etc. You still need to use the geoprocessing tasks as discussed above, so the only thing you can do in JSAPI as of now, is to switch the version of your layer.

To wrap it, here is an example:

mapService= "http://myserver:6080/arcgis/rest/services/mymap/MapServer";
myLayer= new esri.layers.ArcGISDynamicMapServiceLayer(mapService,{opacity: 1});
map = new esri.Map("mapDiv");
map.on('layers-add-result', function(e){
        // just to make sure that the layer is actually loaded
        myLayer.setGDBVersion('A');
    });
map.addLayer(myLayer);
| improve this answer | |
0

if you are using the security manager of ArcGIS Server , i do not Know How you can get data about version of user but if you are using session to manage your user so you can get version of your user form db . set version of user in session and use this value in

setGDBVersion()

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.