This article may help you to understand the Task Manager API functions.
the CompleteTask method will solve your issue.
Now, The matter is how you are going to correlate your TaskId from the WatchedFolder initiated process.
I had look at the API's but as you said my man problem is how do I get the TaskId of waiting process.
As Nith is pointing out you need to know how to link the document with the task id. Once you the link, you might be able to use the TaskManagerQueryService api to search for a task id.
I think when the scanned document is dropped in the watched folder you will need the metadata put there as well. May be you can ask the file name to have blahblahblah_taskid.pdf as the naming convention or the xxxx.pdf and xxxx.txt files are dropped there and the .txt file has the task id and your watch folder is looking for .txt files as the trigger.
The other way I've solved similar problem is through email endpoint. Just before the task creation you can send an email with process id and other info in subject line. The user either completes the task via option a or he replies to the email with attachment. Then the email endpoint will pick up the email and you'll get the process id from subject which will allow you to find running task. Then after use the links that these guys posted to create the complete task call.
hope that helps.
blog - http://blog.pandyaparth.com
Thanks for your advise. In my case I can't ask them for a prefixing task id to scanned document as the scanning will happen remotely and they will not know what task id / process id is and second option is also not possible.But we do name the scanned files to have specific identifier ( Order no) which is understood by our system and based on this I can get process Instance Id. I am not sure how do I retrieve Task Id based on process Id and I also struggling to understand how can I make use Live cycle API in this scenario.
1) Get the Task Id Based on Process Instance Id, as this task could be sitting with any user ( how can I filter all tasks in system? As when i use any Task Filters it returns me task assigned to that user)
2) How to complete the task assigned to other user using a standard system user using Java API?
I think you are looking at creating either a custom DSC or writting the logic in script component.
The LiveCycle api references given in this thread will help you to write this logic.
When the task is assigned to a user you should only complete it with the custom dsc or script. LiveCycle SDK help has examples that will give you a good start point.
When you'll complete the task the process will move to next step in process. You will not need to worry about which user has that taks as the API call will complete the task as System user and the task will get removed from user's queue and next process logic will get executed.
I have managed to get the Task Id but I am still not able to use the completeTask method as this task is assigned to different user and when I am trying to complete it using user credentials which have admin roles assigned it throws following error,
com.adobe.idp.taskmanager.dsc.client.task.TaskPermissionException: User: CA9F4E72-82FA-9048-C526-E2E45B0BE61C is not assigned task: 12203. The task cannot be completed
does the admin user needs to have specific permissions to complete task on behalf of other user?
There are many Administrator roles available ; e.g Process Administrator/Forms Administrator etc.
But did you try with Super Administrator account?
If still not working, as a quick solution you can claim the task to your account and complete the Task.
Please note that this will be recorded and your account name will appear on tracking.