Skip to main content

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

 

 

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.


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

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

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 :-)


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

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


Great, thanks!


Reply