Skip to main content
Solved

Modify the List output of user parameters

  • October 11, 2022
  • 9 replies
  • 117 views

Forum|alt.badge.img

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.

 

Best answer by dustin

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

9 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • Best Answer
  • October 11, 2022

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


Forum|alt.badge.img
  • Author
  • 5 replies
  • October 11, 2022

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

 


danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2076 replies
  • October 11, 2022

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!


Forum|alt.badge.img
  • Author
  • 5 replies
  • October 27, 2022

@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.


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • October 27, 2022

@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.


Forum|alt.badge.img
  • Author
  • 5 replies
  • October 31, 2022

Hi @dustin​ 

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


danminneyatsaf
Safer
Forum|alt.badge.img+13
  • Safer
  • 485 replies
  • November 1, 2022

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.


Forum|alt.badge.img
  • Author
  • 5 replies
  • November 3, 2022

@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


danminneyatsaf
Safer
Forum|alt.badge.img+13
  • Safer
  • 485 replies
  • November 14, 2022

@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!