Issue: Recently I worked on an issue for a customer who reported a problem with Process ID value becoming “-1”.
Scenario: Customer had a process where they were naming the output file using a combination of “Process ID + time-stamp”. They reported that the value of the output filename was coming up as “-1+time-stamp” for some files.
Trouble-shooting: Upon reviewing their process, the design was – A long-lived process takes an input from a watched-folder end-point and checks to see if the incoming file is a TIFF, MS Word document or XML data file. If the input was any other format other than XML, then these files would be converted to PDF’s and the output file would be named as “Process-ID+timestamp” and stored in a directory. If the input file was an XML data file then it would be sent to a sub-process and merged with a form-template and flattened and then named as “Process-ID+timestamp” and stored in the same output directory. By running some tests, we could see that the file name would come out as “-1+timestamp” only when the input file was an XML data file.
The Parent process was a long-lived process and the sub-process was a short-lived process. When the files were named using the ProcessID within the long-lived process, everything was working fine. The issue was with the XML data files when they were passed to the short-lived sub-process, because the processID of the short-lived process was being used to name the output files in the sub-process.
So the processID part of the output file name was being generated using
ProcessID = /process_data/@id
The problem with this is, for short-lived processes there is no Process ID as they are not being stored in the Database. Hence the /process_data/@id was returning ‘-1’ as the value.
Resolution: To resolve this issue, we stored the processID of the parent process in a string variable (named ParentPID) and passed this variable to the short-lived process. And for generating the output file name within the short-lived process, we assigned ‘ProcessID = ParentPID’ and then used this for the output file generation. This resolved the issue.