Question

User parameter - Date Time Now as Default value

  • 25 October 2018
  • 1 reply
  • 89 views

Badge +2

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

Userlevel 4

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.

Reply