Skip to main content

When a ParameterFetcher (or AttributeCreator/Manager) is used to obtain the values of a "Choice (Multiple)" published parameter the result is a space-delimited string. However, when any of the published parameter choices contain spaces the values are wrapped in double quotes. If there are no spaces in the choice value then it is not wrapped in quotes. This makes extracting the actual chosen values problematic in an FME workspace.

As an example, if my published parameter choice values are:

  • 'a a'
  • 'b'
  • 'c c'

Then the ParameterFetcher would return an attribute with a string containing:

  • "a a" b "c c"

It is not a simple task to retrieve the individual choice values from this string. The AttributeSplitter will not work because the delimiter <space> can appear in the quoted strings. A simple regex is not easy to construct because not all values are quoted. The simplest solution seems to be a TCLCaller or PythonCaller but this is not easy for someone with limited programming experience.

My idea suggestion is to make accessing these values easier. To do this I would propose two alternative solutions:

  1. wrap all values in quotes, even if they do not contain spaces, to make constructing a regex simpler;
  2. enhance the ParameterFetcher to return an FME list of the choice values.

I had the same problem and found this post. I agree with @nic_ran's idea, but in the meantime, the Python code below will do the job.

I used "inClause" in this code to hold the modified string because I want to make the user's choices into an IN clause in a database lookup:

# What comes out of the choice (Multiple) parameter # Two spaces in Building Foot Print, one space in Bike Route featureClassLabel = '"Building Foot Print" BIA "Bike Route" Areaway' inClause = "" isStartQuote = False for character in featureClassLabel: if character == '"': if not isStartQuote: # starting quote isStartQuote = True continue else: # ending quote isStartQuote = False continue else: if isStartQuote: # search for the space between the quotes if character == ' ': inClause += '::' # replace the space with ::. It could be any characters, though else: inClause += character # default; just add the character to InClause else: inClause += character # default; just add the character to inClause # inClause now looks like this # Building::Foot::Print BIA Bike::Route Areaway inClause = inClause.replace(' ',"','") # You are free to replace the spaces now inClause = inClause.replace('::',' ') # Now replace the :: back to spaces inClause = "'%s'" % inClause print inClause # inClause now looks like this # 'Building Foot Print','BIA','Bike Route','Areaway'

To execute this code in a PythonCaller you first have to create an attribute from the parameter, then use

def processFeature(feature): featureClassLabel = feature.getAttribute("cboFeatureClassLabel")


I struggled with this issue too but the simple solution was hiding in amongst advanced regex usage.

Here is an example of a multi-choice parameter value as returned to a workspace:

Intersection Subaddress "Distance Marker" "Point Address" "Street Address" "Street Name"

Using a StringReplacer first replace spaces not followed by words ending in a double quote.

The expression is: s(?![w]+")

I replace matches with a comma, in my example this yields:

Intersection,Subaddress,"Distance Marker","Point Address","Street Address","Street Name"

In my case (using Esri's geocodng API) I also needed to remove the double quotes with a second StringReplacer, yielding:

Intersection,Subaddress,Distance Marker,Point Address,Street Address,Street Name

The fancy regex is called negative lookahead.