Getting an error while trying to script it, specifically "Cannot use VB for services." Snippet and VB code block as follows:

Raw block (works within ArcMap): "\ftp\raw\YYYYMMDD\Files\Charles" +[NAME]+".ntf"


    date = '"20160207"'

    arcpy.CalculateField_management(outShp, "Link", '"\\\\ftp\\raw\\"' + date + '"files"' + "[NAME]"+ '".shp"', "VB", "")

Not sure what the issue is, somehow need to be able to insert the date and have it syntactically be correct (in either VB or python).

I didn't explain very well I have a column that contains a portion that is part of the hyperlink, so need to concatenate A column to the end of B column (with the partial path) to complete the link

  • USe r"............" syntax. Might work w python – FelixIP Feb 8 '16 at 6:51
  • Looks like in 10.1 it won't allow you to use VB for calculate field in python, although not entirely sure how to do it syntactically in python. – geodranic Feb 8 '16 at 7:21
  • "Cannot use VB for services." - This error usually appears when trying to calculate fields using VB when you have background 64 bit geoprocessing enabled. Turning off background geoprocessing should get you past this error – Midavalo Feb 8 '16 at 8:32
  • See if !name! Will work. Alternatively use python window on calculator and copy syntax from result window – FelixIP Feb 8 '16 at 8:59
  • Nothing for the !name!, I ran the calculate field tool with the VB syntax (it worked), copied the python snippet, pasted into my script exactly... and the exact same syntax is invalid – geodranic Feb 8 '16 at 10:34

I hope I understood your problem sufficiently. As far as I got it, I would try the following:

# predefine the constant parts of your expression using a variable:
constant = "\ftp\raw\YYYYMMDD\Files\Charles"
nameVar = "yourobject.Name"

# use the built in function .format for setting up the expression for your arcpy.CaculateField_management function:
expression = """{0}\{1}files{2}.shp""".format(constant, date, nameVar)
arcpy.AddFieldDelimiters("yourworkspace", expression)

# then simply use the expression variable in your arcpy function:
arcpy.CalculateField_management(outShp, "Link", expression)

If you want to put togehter paths and file names, you could look into the os.walk or arcpy.da.walk tool. Also, should there remain problems with the SQL-expression, try the arcpy.AddFieldDelimiters() tool. Hope this helps.

Edit 9th of February 2016: Since you're saying that your syntax is working within the main tool but not in the script, I suggest checking your paths. Avoid gaps and special characters. Also try checking the "store relative path names" under the general tab of your script properties. Have you tried the arcpy.AddFieldDelimiters() function yet? Good luck.


An easy way to get the script translated to python would be to create a Model, here are the steps:

  1. Create a blank model
  2. Add the Calculate Field tool, fill out everything using the UI, run it
  3. If it runs as desired export the model to python script, Model menu>Export>To Python Script. The syntax should run in python for either the originally set parser (VB or python).

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.