Hi,
Â
Â
it seemsÂ
it is still documented, for what it's worth. It might be that the value is undefined after the workspace terminates its processing.
Â
Â
Do you get the value if you access FME_MacroValuesa'FME_JOB_ID'] from a PythonCaller? If so, you could write out the value to a global Python variable and later retrieve it during your shutdown script.
Â
Â
David
no success with PythonCaller either.
Â
code:Â
   global my_glob_job_idÂ
   try:Â
       my_glob_job_id = FME_MacroValues['FME_JOB_ID']Â
   except:Â
       my_glob_job_id = 'no_job_id_access'Â
Â
and in shutdown script i have 'no_job_id_access' for my_glob_job_id
Hi,
Â
Â
just to verify: you're running this from FME Server, right? I'm asking since FME_JOB_ID isn't available from FME Desktop.
Â
Â
If you still can't get it to work, I'd consider sending the issue to Safe.
Â
Â
David
yes, from server,
Â
FME Server 2013 / linux
Â
Â
thanks David,
Â
seems it really better first to clarify with Safe that server provide job_id at runtime.
The job_id is not available to the shutdown script.
Â
Â
One method that I've employed in the past is to write the job ID to the log file when the translation is running and then read it back out in the shutdown script.
Â
Â
Here's my python function for parsing the log file:
Â
Â
# Searches the log file for attribute values and returns them as a list.
Â
#
Â
# Attribute values are expected to be written to the log file, one per line, in the
Â
# format:
Â
#Â Â __logAttr_<attrName>:<attrValue>
Â
# e.g.
Â
#Â Â __logAttr_JOB_ID:99
Â
#
Â
def ParseAttrsFromLogfile():
   # Get a handle on the log file
Â
   logFileName = FME_LogFileName
   attrs = {}
Â
   allText = open(logFileName, 'rb').read() # read whole log file into 1 string
Â
   rex = re.compile(r'__logAttr_(Â^:\\s]+):(.+)\\r', re.I | re.M)
Â
   rslts = rex.finditer(allText)
Â
   for rslt in rslts:
Â
       if rslt.group(1):
Â
           attrs rslt.group(1)] = rslt.group(2)
Â
   return attrs
Â
To write an attribute to the log file during the translation I had to use the TCLCaller transformer (I wasn't able to do it with Python).
Â
Â
My TCL proc for writing the attributes to the log file is below. This proc assumes that the names of the attributes to log are a comma-seperated list in a feature attribute called "_ATTRS_TO_LOG":
Â
Â
proc LogAttributes {} {
Â
  Â
Â
   set attrNames >split >FME_GetAttribute _ATTRS_TO_LOG] ,];
Â
   #FME_LogMessage fme_inform __LOGGED_ATTRS:tFME_GetAttribute _ATTRS_TO_LOG];
   foreach attrName $attrNames {
Â
       set aName tstring trim $attrName];
Â
       FME_LogMessage fme_inform __logAttr_$aName:ÂFME_GetAttribute $aName];
Â
   };
Â
}
Â
 Good luck!
Â
Â
Hi, It works for me on Windows, build 13450 (service pack 1).
Â
I believe this was added in sp1, could your server-side FME Engine perhaps have an earlier build (check first line of server-log-file)?
Â
Â
/Peter
thanks all,
Â
FME_JOB_ID added in FME 2013 SP1 and there was no available in 2013 release. Updating to latest build helps.
Â
thank you all for suggestions
Â