Question

Dynamic Conditional Parameters

  • 28 October 2013
  • 4 replies
  • 21 views

Is there a way that parameters can dynamically change based on other published parameters?

 

 

For example the initial parameter could be 'AssetType' the choices would be Water, Sewer, Drainage... then the second parameter would be 'Location' and depending on what was selected as AssetType this list would be different.

 

 

The only way I can think of at the moment is to have 2 parameters called 'SewerLocation' and 'WaterLocation' with different values available, it would be preferable if there was a better way.

4 replies

Userlevel 2
Badge +17
Hi Chris,

 

 

Assume a Location is associated with an AssetType by 1 to 1.

 

If the AssetType will not be used in the translation directly, "Choice with Alias" parameter can be used to map AssetType (Display Name) to Location (Value).

 

If not, the Scripted (Python / Tcl) Parameter could be a solution; it can be used to create a parameter value depending on other parameter value.

 

This is a Scripted (Python) Parameter example: ----- # Map AssetType to Location by 1 to 1. assetToLocation = {   'Water' : 'Location Foo',   'Sewer' : 'Location Bar',   'Drainage' : 'Location FooBar' }   # Get the value of other parameter named "AssetType". assetType = FME_MacroValues['AssetType']   # Return the Location associated with the AssetType. if assetType in assetToLocation:     return assetToLocation[assetType] else:     return 'Undefined Location' -----   Reference link:

 

Scripted (Python) and Scripted (Tcl)

 

http://docs.safe.com/fme/html/FME_Workbench/Default.htm#Parameters/scripted_python_tcl.htm

 

Takashi
Thanks for the reponse.

 

 

I may not have explained it very well. The location wouldn't be associated with an asset type on a 1:1 basis.

 

 

Please see example explained a bit further below;

 

 

AssetType
  • Water
  • Sewer

 

If Water is selected then Location parameter would display
  • Town A
  • Town B
  • Town C...

 

If Sewer is selected then the Location parameter would display
  • Town X
  • Town Y
  • Town Z...

 

Regards

 

Chris

 

Userlevel 2
Badge +17
Ah, you want to create dynamically the choice list of a Choice type parameter...

 

 

The parameter definition (including choice list) is static, I don't think it's possible to define the choice list of a parameter at run-time, unfortunately.

 

As you say, defining multiple Location parameters for each AssetType would be a good solution. e.g. SwereLocation, WaterLocation and more.   The way to create dynamically a choice list (but it's not in a usual parameter)  I can think of is: create FME Parameter Dialog Box with a choice list based on the AssetType in the Startup Python Script, save the selected location as a global variable, and get the value with a PythonCaller.

 

My post in this thread could be a hint of how to do that.

 

Message or Alert Box

 

http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000cojVAAQ

 

 

This way will be an interesting challenge, but it could be difficult to maintain in the future since it is a little complicated. I don't know whether it will be better solution.
Userlevel 2
Badge +17
p.s. I confirmed that an FME Parameter Dialog Box with a choice list can be created dynamically in a Scripted (Python) Parameter. In this way, since the selected Location will be set to a parameter, you don't need to use a global variable and a PythonCaller.

 

Although this may not be a general way, I'll provide a script example if necessary.

Reply