Question

How to publish a choice parameter from script?

  • 23 September 2022
  • 3 replies
  • 10 views

Userlevel 1
Badge +8

I need to have a choice parameter offering all the database tables of a specific database for the user to choose from before running the workspace.

I do have the Python code ready, and created a scripted parameter, returning a list of all table names.

I referenced the scripted parameter as input for the choice parameter, but that only gives me a dropdownbox with the name of the parameter linked to it.

 

Is it possible to populate a choice parameter from a Python script (scripted parameter), and if so how?


3 replies

Badge +10

Unfortunately, I don't think you'll be able to populate the choice parameter with a scripted parameter automatically. the closest option available is importing the choices from a dataset and the importing process has to be done manually, each time you want to update the choices

image

Userlevel 1
Badge +8

Thank you for your answer, even though that's a bummer...

Userlevel 3
Badge +17

Hello @Thomas Becker​ 

@carmijo​ is correct. The reason being parameter values are set at the very start of a workspace (at runtime) plus it is not possible to modify the value of a parameter after it has been set. So it is not possible for the Python scripted parameter to pass its values to the choice parameter and modify the choice parameter within the same workspace.

 

However, this post on dynamic but hacky updates to published parameter choices contains a workaround that might suit your use case.

 

I would definitely recommend voting on this Idea about dynamic lookup parameters if you want to this functionality within FME natively.

Reply