Skip to main content
Question

User parameter - Date Time Now as Default value

  • October 25, 2018
  • 1 reply
  • 574 views

philippeb
Enthusiast
Forum|alt.badge.img+20

Hi!

I'm trying to create in FME Desktop a published parameter that contains the date time now as a default value.

After publishing my script on FME Server, when I go on the web page calling that parameter, I'm not getting a value. I get the function string.

I tried to choose a Date type in my user parameter, but I only get a calendar.

Any idea how to get the current date time in a user parameter?

Thanks!

1 reply

david_r
Celebrity
  • October 25, 2018

I don't think that's possible, although it would be very handy!

I've solved this exact same case by having one published, optional parameter of type String (let's call it DATE_GAME), and one private Python scripted parameter (let's call it DATE_GAME_FOR_REAL here).

The definition of DATE_GAME_FOR_REAL could look like this:

from datetime import datetime
date_game = FME_MacroValues.get('DATE_GAME'None)
if date_game:
    return date_game
else:
    return datetime.now().strftime('%Y%m%d%H%M%S')

This function returns the value of DATE_GAME if the user typed anything into the field. If DATE_GAME is empty, it defaults to the current timestamp.

Then in my workspace I never reference DATE_GAME, only DATE_GAME_FOR_REAL.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings