1

Can anybody tell why the field gets updated when I run this script in ArcMap but not when I run a geoprocessing service?

#Import modules
import os, sys, arcpy, traceback, arcgisscripting   
gp = arcgisscripting.create(10.1)
Stewardship = gp.GetParameterAsText(0)  
Officevar = "\"College Station\""
# This is to send the data input to the database
with arcpy.da.UpdateCursor(Stewardship, ("City")) as rows:
     # row comes back as a tuple in the order specified here, so Office is row[0], Forester is row[1]
        for row in rows:
            row[0] = Officevar     
            rows.updateRow(row)
2

You're updating "Stewardship", which is a going to be one of 3 things: a) layer b) featureclass c) feature set

If I had to guess, you probably started with a featureclass as input. That is, a pointer to something on disk. When you published you probably accepted the defaults in the Service Editor and the featureclass gets mapped to FeatureSet. At this point when you run it, its just a best guess if you've given it features into the featureset when you ran.

This answer is more of a question I suppose, there is a lot of information you need to provide or go back and double check.

  • What are you trying to update in the service? User defined data (feature set) or a featureclass (which would be set to constant)
  • Have you checked the input parameter in the service editor to make sure it matches what you want
  • Does your published service look the same as the tool before you published it when you consume it in ArcMap. (this answer really determines what has happened when you published)
  • If you're using a featureclass which is hard coded, have you set the datastore, so it isn't making a copy of the data into the arcgisserver directories? Along this line, how do you know that the field isn't being updated, what data are you looking at? Are you certain that data is the data the GP Server is acting against?
  • Hi Khibma,Thank you for helping. I want to update a feature class, but it would update only one row if I set parameter as a featureset, because the user chooses only the selected layer, so perhaps this is the issue? The input parameter shows "user defined" in the service editor. The service looks the same, it asks for the same parameter.I am not using a hard-coded featureclass. Could it be that is updating the layer that I choose in ArcMap but not the feature class? What would be your advice in using a feature class as parameter, but having only the selected record updated? Thank you so much! – ionara Sep 27 '13 at 16:43
  • The feature gets updated in ArcMap although I am actually only choosing the selected layer as the input. – ionara Sep 27 '13 at 16:44
  • If I were to update (the same) featureclass everytime, I'd hardcode it (it doesnt seem to make sense for the user to submit this data). Its still not clear how the user is choosing what row to update. Perhaps they're passing a string to act as a selection? You can do with with Select and then Calc Field, it'll only update the 1 row. You could still do the cursor, but again I'm confused. I think you should go back and just explain your goal. I can provide suggestions, but they're just shooting in the dark at this point. – KHibma Sep 27 '13 at 16:47
  • I am letting the user submit the data, because the user will digitize a polygon first and then that information that he entered will be applied to the record he digitized (I will later change that city parameter to a parameter that the user can add to the record, instead of being hard-coded like it is now). Later I will test this using a feature service, but I am trying to make it work first with a geodatabase in my local drive – ionara Sep 27 '13 at 16:52
  • Also, this geoprocessing service will later be used in a web app. I already have the web app in javascript working, using the edit widget. The user will digitize the polygon, then he will run this geoprocessing script to do some calculations, but I am doing a test just with a simple snippet to see if the feature class can get updated. – ionara Sep 27 '13 at 16:58

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.