Select to view content in your preferred language

cannot use VB expressions for services

4957
5
11-06-2012 09:57 AM
KevinGooss
Regular Contributor
10.1 geoprocessing tool.
I'm getting an error during the analysis phase in ArcCatalog while trying to publish my gp service. It says I can't use VB expressions in the Calculate Field Tool. The severity is High but i am still able to publish.
Here is the only line in my py script that uses the CalculateField tool:

arcpy.CalculateField_management("in_memory/buffer", "GP_ID", "x", "PYTHON", "x = '" + uniqueid + "'")


Am i missing something? Because I don't think there is any VB in there.
0 Kudos
5 Replies
AnthonyGiles
Honored Contributor
Kevin,

Using Server 9.3.1 you have to change the Expression Type parameter to 'PYTHON_9.3'. For the calculate field to work.

http://support.esri.com/en/knowledgebase/techarticles/detail/36571

Not sure if this is still the case with 10.1, but worth looking at

Regards

Anthony
0 Kudos
KevinGooss
Regular Contributor
no dice. but thank you for the suggestion.
0 Kudos
KevinHibma
Esri Regular Contributor
Its not an error, just a high-warning.
Check the help here:
http://resources.arcgis.com/en/help/main/10.1/index.html#//005700000093000000

Specific to your case:

Solution
    If your tool is not using a VB expression, you can ignore this warning.


Per Anthony's response, the KB article still holds true...we now have the ability (in 10.1) to let you know about it and offer suggestions.
0 Kudos
KevinGooss
Regular Contributor
Cool. Thank you.
0 Kudos
AnthonyGiles
Honored Contributor
Kevin,

Not that I am an expert in python but looking at the help file for Calculate Field the syntax is:

CalculateField_management (in_table, field, expression, {expression_type}, {code_block})

so if uniqueid is a variable have you tried:

arcpy.CalculateField_management("in_memory/buffer", "GP_ID",uniqueid,"PYTHON")

or if uniqueid is a field name

arcpy.CalculateField_management("in_memory/buffer", "GP_ID", "!uniqueid!","PYTHON")

Regards

Anthony
0 Kudos