Alter Version tool, input name contains "\n"

175
3
07-10-2019 01:27 PM
Steve_Salas
Occasional Contributor

Feature services that create enterprise geodatabase edit versions are building version names in the format of "DOMAIN\username_servicename"  I have a Python script that attempts to rename the edit version when certain conditions are met.  However if the username starts with a lowercase "n", the tool interprets this as a Python newline and cannot find the version.

Successful:

arcpy.AlterVersion_management(sdeConn,"DOM\jdoe_testing","edits_jdoe","","PROTECTED")

Not Successful:

arcpy.AlterVersion_management(sdeConn,"DOM\ndoe_testing","edits_ndoe","","PROTECTED)

Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 18176, in AlterVersion     raise e ExecuteError: ERROR 999999: Error executing function. Version not found [SRVR.DOM doe_testing] Failed to execute (AlterVersion).

DOM\ndoe_testing becomes DOM doe_testing

The Alter Version tool in ArcToolbox will let you select the edit version after identifying the database connection, but it populates as (from the example above) as "SRVR.DOMdoe_testing".  That allows the tool to start executing, but fails with the error of not being able to find the version.

I've tried what I know with raw strings, double backslash, changing to all uppercase for the version name with no success.  Anyone else experienced this and found a workaround?

0 Kudos
3 Replies
DanPatterson_Retired
MVP Esteemed Contributor

have you tried making it a variable

dom = r"DOM\ndoe_testing"
arcpy.AlterVersion_management(sdeConn, dom, "edits_ndoe", "", "PROTECTED")

and you were missing a double quote at the end of "PROTECTED" in case it was a copy issue

0 Kudos
Steve_Salas
Occasional Contributor

Sorry - poor copy/paste skills on my part...  I did try making it a variable, same result:

Version not found [SRVR.DOM doe_testing] Failed to execute (AlterVersion)

 

I've also tried using the output of arcpy.ListVersions(sdeConn) to get the name:

u'SRVR.DOM\\ndoe_testing' so I pull that item from the returned list and use it as the input name.  Same error as above.  Maybe we just block users named Nick, Ned, Nancy, etc from using the system altogether. 

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

You might want to flag this to tech support.... I would be surprised if you are the first that has had this issue.. or you are the start of a wave