Please answer the following questions to narrow down the problem statement..
1. Is your process is short-lived?
If yes, there won't be any process Id created. You will always get -1 as process Id
2. While playback of process recording, do you see a ProcessId created and lost when the PDF is flattened?
To check that, create a process variable of type long and assign /process_data/@id value to it. Then see the recording what value is saved in your variable.
If you cascade the process, I mean if you call a sub process (short-lived) from a main process (which is long-lived), you can pass the parent process's ProcessId so that you will get a real number that can be used as filename.
Non confidential process/forms can be shared with email@example.com for further troubleshooting.
Here are my answers:
1. The process is a long-lived one.
2. While playback of process recording, I do see the processID (PID) when I assisged it to the process variable. It just got lost after when it writes the flatten pdf file to the folder. Note that the folder is located on the LC server.
3. That's what I have been trying to do by calling a short-lived (sub-process) from a main long-lived one to pass the PID but for some unknow reason, I keep having the above issue.
The strange thing is if I copy the whole sub-process into the main process instead of drag it into the main process as a service then it works just fine which is recommended to do.