How to dynamically populate in a published parameter based on the output of an attribute column?
Hello everyone,
I have a column with output that changes depending on different input.
Ideally, I would like to populate a published parameter (Choice) based on the output of that column, so then a user can click on a value of that choice list on FME Server in let's say a workspace app.
Does anyone know how to dynamically fill in a choice list based on the output of a column?
Page 1 / 1
It's not possible in a single workspace since parameter values are established at runtime, meaning they can't be retroactively published after you click Run. I haven't personally tried but this article outlines a similar process to what you are describing using a two step process. EasyGeocoder - Data Driven Self-Serve Data Transformation (safe.com)
It's not possible in a single workspace since parameter values are established at runtime, meaning they can't be retroactively published after you click Run. I haven't personally tried but this article outlines a similar process to what you are describing using a two step process. EasyGeocoder - Data Driven Self-Serve Data Transformation (safe.com)
How did you use a FeatureReader transformer to do this, or at least get close to doing it?
Probably the best way to get the Feature Types to Read parameter is to throw down a FeatureReader and then create the parameter directly from within the transformer
@virtualcitymatt this was exactly what I was looking for! Thank you so much!
I managed to execute what I needed within FME Form (dynamically providing a selection list within a user parameter), however, now I am running into issues on Flow, ugh!
The structure of my workflow is:
1. I have one workbench uploaded to flow that runs every night. It generates a CSV with layer names. Within that same workbench, it uses a sqlite writer to write those names as tables to a sqlite file. Example, 138 values were written to the CSV, and then in a single sqlite file, there are 138 tables with those same layer names.
2. In the main workbench, I have a Creator into FeatureReader that reads the sqlite file, and then in Feature Types to Read, I have the user parameter.
When I run the workbench, the user parameter dynamically populates based on those values in the CSV. Perfect, it's exactly what I needed, however, the problem comes when publishing this to Flow.
When I publish the workbench to Flow, the user parameter is empty.
I tried following the second section in the article by @mark2atsafe, where, I read the CSV file, aggregated each value onto 1 line with % as the concatenation value, and then used the AttributeReader to bring in the .fmw file. I then found the section of the user parameter and used a string replacer to replace with the aggregated attribute, and then used the AttributeWriter to overwrite the .fmw file. For some reason, however, the values are not showing up in the parameter, both in Form and on Flow.
@virtualcitymatt this was exactly what I was looking for! Thank you so much!
I managed to execute what I needed within FME Form (dynamically providing a selection list within a user parameter), however, now I am running into issues on Flow, ugh!
The structure of my workflow is:
1. I have one workbench uploaded to flow that runs every night. It generates a CSV with layer names. Within that same workbench, it uses a sqlite writer to write those names as tables to a sqlite file. Example, 138 values were written to the CSV, and then in a single sqlite file, there are 138 tables with those same layer names.
2. In the main workbench, I have a Creator into FeatureReader that reads the sqlite file, and then in Feature Types to Read, I have the user parameter.
When I run the workbench, the user parameter dynamically populates based on those values in the CSV. Perfect, it's exactly what I needed, however, the problem comes when publishing this to Flow.
When I publish the workbench to Flow, the user parameter is empty.
I tried following the second section in the article by @mark2atsafe, where, I read the CSV file, aggregated each value onto 1 line with % as the concatenation value, and then used the AttributeReader to bring in the .fmw file. I then found the section of the user parameter and used a string replacer to replace with the aggregated attribute, and then used the AttributeWriter to overwrite the .fmw file. For some reason, however, the values are not showing up in the parameter, both in Form and on Flow.
Yeah too bad it doesn't work in FME Flow
That’s right - the workspace method now is a bit more tricky. Since the change of the UI for the parameters, I think back with FME 2022, the whole user parameters section is now encoded in json. The JSON parameters are then serialized as a base64 string in the workspace.
The line you want to look at starts with “FORM” e.g.,
if you want to use this method then you will need to extract this base64 string, decode it, modify the JSON, reencode it and then update the workspace. Just don’t expect it to keep working with updates to FME versions. This is something to do only if you’re desperate and if you’re prepared for it to break. - You may also break your workspace so make sure you have a back up!
Thank you very much for taking the time to provide such thorough explanations, @virtualcitymatt .
I had no idea that the user parameters are now encoded in JSON, that certainly clears up the problems and confusion I was experiencing.
Out of curiosity, I examined FORM="XJlZCI6dHJZSwiZGVsdFWNlU2V0dGluZ3MiOnsiY2hvaWNlU2V0Ijoi" by decoding and formatting it, and indeed, the values were clearly there.
@mark2atsafe had come up with a very smart approach for handling this, but as new FME versions come out, dynamic user parameters seem to pose a new set of challenges. Hopefully, there will be other effective solutions available in the future.
Once again, thank you, Matt, for all of your guidance and info. I sincerely appreciate it.
Thank you very much for taking the time to provide such thorough explanations, @virtualcitymatt .
I had no idea that the user parameters are now encoded in JSON, that certainly clears up the problems and confusion I was experiencing.
Out of curiosity, I examined FORM="XJlZCI6dHJZSwiZGVsdFWNlU2V0dGluZ3MiOnsiY2hvaWNlU2V0Ijoi" by decoding and formatting it, and indeed, the values were clearly there.
@mark2atsafe had come up with a very smart approach for handling this, but as new FME versions come out, dynamic user parameters seem to pose a new set of challenges. Hopefully, there will be other effective solutions available in the future.
Once again, thank you, Matt, for all of your guidance and info. I sincerely appreciate it.