Skip to main content
Best Answer

setting a parameter depending on the environment

  • May 6, 2020
  • 5 replies
  • 37 views

vki
Contributor
Forum|alt.badge.img+7

I want to set the value of an attribute, depending on the environment, where my workbench is running (desktop, server dev, server prd),. I could do this with an parameterFetcher and get e.g. FME_SERVER_HOST. But I don't want to do this for each feature, but just once at the beginning.

What's the best way to do this?

I tried it with a scripted parameter, but I get an error, for FME_SERVER_HOST is not know when I run the workbench on desktop.

Then I tried it with a startup-script. Here I don't get an error, but how can I set a parameter here, that I can use in the workbench?

Thanks, Vera

 

 

Best answer by takashi

A possible workaround is to create a Python scripted parameter like this.

import fme
return fme.macroValues.get('FME_SERVER_HOST', 'https://foo.com')
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.

5 replies

david_r
Celebrity
  • May 6, 2020

Try using something like the following in a scripted parameter:

import fme
host = fme.macroValues.get('FME_SERVER_HOST', None)
if host:
    # Running on FME Server
    return host
else:
    # Running on FME Desktop
    return 'development'

This will return the value of FME_SERVER_HOST if running on FME Server, or 'development' if running on FME Desktop.


takashi
Celebrity
  • Best Answer
  • May 6, 2020

A possible workaround is to create a Python scripted parameter like this.

import fme
return fme.macroValues.get('FME_SERVER_HOST', 'https://foo.com')

takashi
Celebrity
  • May 6, 2020

A possible workaround is to create a Python scripted parameter like this.

import fme
return fme.macroValues.get('FME_SERVER_HOST', 'https://foo.com')

The approach is exactly same as @david_r's :-)


david_r
Celebrity
  • May 6, 2020

The approach is exactly same as @david_r's :-)

Indeed, yours is shorter but mine has comments :-)


vki
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 6, 2020

Great, thanks!