1

I'm working on ArcGIS 10.0 sp5. I have a very strange behaviour. In an arcpy script I have these two very simple commands, to add a field "ID_UDF" to a table and then fill it with a value:

arcpy.AddField_management(table, "ID_UDF", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(table, "ID_UDF", '{0}'.format(ID_UDF), "VB", "")

The script is contained in a Toolbox. If I execute the script with ArcGIS Desktop it works fine and the field ID_UDF is correctly added and filled with the value. If I publish the Toolbox with ArcGIS Server and I execute it from there the field is added but not filled, it remains with a NULL value.

In both cases in the Geoprocessing log I have no errors, and both commands (AddField and CalculateField) are successfully executed.

Even if I remove the AddField command (supposingly the field is already created), CalculateField alone is working correctly with ArcGIS Desktop but not with ArcGIS Server. In the script there are many other commands that work fine on both environments.

Any ideas?

  • you are using python command and set type in VB – GeoStoneMarten Nov 26 '15 at 22:39
1
  1. You have create a field in format long. you need add data in this format. But your function return string value "{}".format(x) if ID_UDF is stored in text you can convert it with long(float(id_udf))
  2. If you want calculate field in python replace "VB" by "PYTHON" or "PYTHON_9.3

    arcpy.CalculateField_management(table, "ID_UDF", 
                                long('!FIELDNAME!'), "PYTHON_9.3")
    

note: it's not necessary adding blank value at optional paramter. You can ignore it

  • 1
    With this syntax now it works: arcpy.CalculateField_management(table, "ID_UDF", long(ID_UDF), "PYTHON_9.3", ""). Anyway ArcGIS Desktop and Server have different behaviours... – Giovanni Nov 27 '15 at 11:16

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.