Solved

Modify the List output of user parameters

  • 11 October 2022
  • 9 replies
  • 11 views

Badge

I have added the following items as a list on a user parameters

  1. Rice
  2. Soft wheat
  3. Sunflower
  4. Corn

 

after the user selects the first three options, the output value is displayed on this format

Rice "Soft wheat" Sunflower

 

where as I would want to convert the above output onto the following format

["Rice", "Soft wheat", "Sunflower"]

 

Kindly suggest on how I could achieve the above output.

Thank you.

 

icon

Best answer by dustin 11 October 2022, 14:29

View original

9 replies

Userlevel 3
Badge +26

In your User Parameter, place double quotes around the Value column values. Also, place an underscore in between soft and wheat. We will replace this later on. Using an AttributeSplitter, split the parameter value using a space as the delimiter. This will produce _list containing the chosen values. Next, concatenate the list of values with a ListConcatenator using a comma as the separator character. Lastly, use an AttributeCreator to build your output using [@ReplaceString(@Value(_concatenated),_," ",caseSensitive=TRUE)].image

Badge

In your User Parameter, place double quotes around the Value column values. Also, place an underscore in between soft and wheat. We will replace this later on. Using an AttributeSplitter, split the parameter value using a space as the delimiter. This will produce _list containing the chosen values. Next, concatenate the list of values with a ListConcatenator using a comma as the separator character. Lastly, use an AttributeCreator to build your output using [@ReplaceString(@Value(_concatenated),_," ",caseSensitive=TRUE)].image

Hi ddbrocato, Thank you for the solution. It worked.

I have made a slight modification to the solution you have posted above.

Added the values within "" "" and also added _ instead of spaces as you suggested.

 

Then used the following regex to replace the commas instead of spaces and spaces instead of underscores.

 ["@ReplaceRegularExpression(@ReplaceRegularExpression($(value)," ",",",caseSensitive=TRUE),"_"," ",caseSensitive=TRUE)"]

 

Thank you once again

 

Userlevel 4
Badge +30

In your User Parameter, place double quotes around the Value column values. Also, place an underscore in between soft and wheat. We will replace this later on. Using an AttributeSplitter, split the parameter value using a space as the delimiter. This will produce _list containing the chosen values. Next, concatenate the list of values with a ListConcatenator using a comma as the separator character. Lastly, use an AttributeCreator to build your output using [@ReplaceString(@Value(_concatenated),_," ",caseSensitive=TRUE)].image

great job!

Badge

@danilo_fme​ @dustin​ 

Hello,

 

For some reason, the above solution implemented by me fails on FME server, It messes up with the Double quotes. But there are no such issues on FME Desktop. Any help on this will be appreciated.

 

Output on FME desktop ( is as expected):

["Rice","Corn Grain"]

 

Output on FME server:

[""Rice,"Corn Grain"]

 

Thank you.

Userlevel 3
Badge +26

@danilo_fme​ @dustin​ 

Hello,

 

For some reason, the above solution implemented by me fails on FME server, It messes up with the Double quotes. But there are no such issues on FME Desktop. Any help on this will be appreciated.

 

Output on FME desktop ( is as expected):

["Rice","Corn Grain"]

 

Output on FME server:

[""Rice,"Corn Grain"]

 

Thank you.

Instead of using your string @ReplaceRegularExpression, try replicating that functionality in a series of StringReplacers instead. Sometimes string functions can cause weird errors.

Badge

Hi @dustin​ 

I have tried using StringReplacer still the issue exists. Any other suggestions? Thank you.

Userlevel 2
Badge +10

Hi @dustin​ 

I have tried using StringReplacer still the issue exists. Any other suggestions? Thank you.

@shreyas.udupa​ This looks like it could be a bug to do with FME 2022.1.2 and is something I'm currently investigating. In FME Desktop, if I expose the user parameter into an attribute using the ParameterFetcher and then send this attribute to the @ReplaceRegularExpression string function, I end up getting the following:

[""Wheat","Rice","Corn Grain","Sweet Potatoes""]

 

This is the same output we are seeing on FME Server, so I suspect the two issues are related. I have filed a bug report for this issue, and we will notify you here when a fix has been released. The ticket number is FMEDESKTOP-13379. Sorry about the inconvenience.

Badge

@shreyas.udupa​ This looks like it could be a bug to do with FME 2022.1.2 and is something I'm currently investigating. In FME Desktop, if I expose the user parameter into an attribute using the ParameterFetcher and then send this attribute to the @ReplaceRegularExpression string function, I end up getting the following:

[""Wheat","Rice","Corn Grain","Sweet Potatoes""]

 

This is the same output we are seeing on FME Server, so I suspect the two issues are related. I have filed a bug report for this issue, and we will notify you here when a fix has been released. The ticket number is FMEDESKTOP-13379. Sorry about the inconvenience.

 

@danminneyatsaf​ Thank you for the info and update

Userlevel 2
Badge +10

@shreyas.udupa​ This looks like it could be a bug to do with FME 2022.1.2 and is something I'm currently investigating. In FME Desktop, if I expose the user parameter into an attribute using the ParameterFetcher and then send this attribute to the @ReplaceRegularExpression string function, I end up getting the following:

[""Wheat","Rice","Corn Grain","Sweet Potatoes""]

 

This is the same output we are seeing on FME Server, so I suspect the two issues are related. I have filed a bug report for this issue, and we will notify you here when a fix has been released. The ticket number is FMEDESKTOP-13379. Sorry about the inconvenience.

@shreyas.udupa​ While we haven't resolved the issue for the time being, we did want to mention that we highly recommend against using double quotes for Choice (List) User Parameters. FME by design will not be able to process the double quotes efficiently. This is likely causing all the issues here., including the different results between FME Desktop & Server. I recommend using a workspace that doesn't have the User Parameter choices bounded by quotes (and especially not double quotes).

 

As a workaround, I recommend using the workspace I've attached to this comment. In the workspace the User Parameter for crops is not bounded by quotes. As a result, the functionality of the workspace is the same in both FME Desktop and FME Server. Please give the workspace a try in both FME Desktop & Server (making sure that the workspace matches both of your Desktop & Server versions).

 

Hope this helps!

Reply