Does anyone know if and how you can remove a value from a parameter filter list?
In my case, I am using a python toolbox in ArcGIS 10.2.2 and want a drop down list of all the versions for the person reconciling to choose from. But I do not want to include dbo.DEFAULT and DS.Draft (our QAQC version, child of Draft).
param1.filter.type = "ValueList"
param1.filter.list = [v.name for v in arcpy.da.ListVersions(r"\\gis01\DatabaseConnectionFiles\DataStewardsOnly\GIS_Vector_DS.sde")]
I tried using -=("dbo.DEFAULT", "DS.Draft") and treating it like a list, but am just stuck on how to do this, since I read elsewhere that these act like tuples, and not like lists. And not sure if this must be done in one line of code or can be altered or if I need to use UpdateParams, but seems like that is for updating based on user input.
I am very new to python and scripting.
Best Answer
You are almost there. You just need to test in the list comprehension you get that the
v.name
is not equal to certain strings.EDIT: Alternate approach: if you want to let your users see all versions, but let them run the script only when having a correct version(s) selected, you might do:
When user will click away from the version parameter, a red cross will be shown. If she will try to click OK, an error message will appear:
Read more about tool validation at Customizing tool behavior in a Python toolbox
If you do not want to run a tool if a user has chosen multiple valid versions, then: