Hello all
I have a one line python script that looks like this:
arcpy.CalculateField_management(r"DemandPoints1","from1",'"aaa"',"PYTHON_9.3")
from1 is a text field in DemandPoints1 and I would like to put the value aaa in it.
This script runs with no problem as tool (no parameters) in ArcMap but when I try to publish it as geoprocessing service I get:
24046: Tool <value> cannot use VB expressions for services
There are many examples of complex calculations but I would like to make it simple!!
Any ideas?
exclamation marks for fields when using python ie !FieldName! could be the issue
I know that! I need to put a VALUE not a field value.
Hi Mody,
Can you provide us more information like,
ArcGIS server installed on which OS?
Is there only issue with this GP process?
From first look like is related to selection on labeling.
I am using ArcGIS Server 10.3.1 on windows.
The tool is published and works. It just gives warning (level High) when I analyse before publishing.
Looks like a bug to me.
Ohh
Thanks for the information.
it is a warning as documented here http://server.arcgis.com/en/server/latest/publish-services/windows/24046-tool-cannot-use-vb-expressi... and http://support.esri.com/Search-Results#search?q=24046 for more
Hi Dan
Thanks, as usual you are correct.
They only problem is that I do not have any VB expression in my python code.
That is why I think it is a bug.
Which is why I pointed it out... it said to ignore it if you don't have a vb expression or to fix it if you do. Confusing needless to say, but perhaps the simple example that you were testing is too simple and 'it' thinks it is vb.. perhaps try something more complicated (well not really) but is truly python...
"{}".format("aaa") which of course yields 'aaa'
After running the tool in ArcMap, if you go to Geoprocessing > Results and right-click on Calculate Field and select Copy As Python Snippet, it produces the following code:
# ArcMap 10.2.1 - Fails, doesn't like """"aaa""""
arcpy.CalculateField_management("DemandPoints1","from1",""""aaa"""","PYTHON_9.3","#")
# ArcMap 10.5 - Success
arcpy.CalculateField_management(in_table="DemandPoints1", field="from1", expression="'aaa'", expression_type="PYTHON_9.3", code_block="")
Here are other variations I have tried:
arcpy.CalculateField_management("DemandPoints1","from1","{}".format("aaa"),"PYTHON_9.3","#") # fails
arcpy.CalculateField_management("DemandPoints1","from1","{}".format("'aaa'"),"PYTHON_9.3","#") # success
arcpy.CalculateField_management("DemandPoints1","from1",'aaa',"PYTHON_9.3","#") # fails
arcpy.CalculateField_management("DemandPoints1","from1","aaa","PYTHON_9.3","#") # fails
arcpy.CalculateField_management("DemandPoints1","from1","'aaa'","PYTHON_9.3","#") # success