Expand my Community achievements bar.

Problem in TaskManager.save()

Avatar

Former Community Member
Hi,



I have written a code for process kickoff.

It successfully kickoff the process and created the process id and task id.

Then, I have retrieved the task id and called TaskManager.save(created_task_id, FormInstance obj);



But, it throws the following exception:

com.adobe.idp.taskmanager.dsc.client.task.TaskNotFoundException: no task found for task ID = 208

at com.adobe.idp.taskmanager.dsc.service.TaskManagerServiceImpl.saveInternal(TaskManagerServiceImpl.java:4481)

at com.adobe.idp.taskmanager.dsc.service.TaskManagerServiceImpl.saveFormData(TaskManagerServiceImpl.java:474)



My Code:

Properties connectionProps = new Properties();

connectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");

connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");

connectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");

connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");

connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");



ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);



TaskManager task = TaskManagerClientFactory.getTaskManager(myFactory);



URL url = new java.net.URL("xdp path");

Document doc = new Document(url);

InputStream in = doc.getInputStream();

byte[] formarray = new byte[in.available()];

in.read(formarray);



FormInstance form = task.getEmptyForm();

form.setTemplatePath("xdppath");

form.setXFAData(formarray);

form.setDocument(doc);



SaveTaskResult result = task.save(taskID, form);

System.out.println("ActionFromData="+result.getActionFromData());

System.out.println("task id="+result.getTaskId());



Please provide the solution.



Thanks in advance.



Regards,

Saravanan
8 Replies

Avatar

Level 10
Are you sure your item is at task id 208. It creates a task id when you open the form from workspace, then when you submit and send it to a user, it'll get another task id.



I suggest you go under the adminui (localhost:8080/adminui)under Services/Process Management/Task Search and make sure you're using the right task id.



Jasmin

Avatar

Former Community Member
You must have the wrong task ID. I tried running the code and it works - here is the code that i used:



try{

//Set connection properties

Properties ConnectionProps = new Properties();

ConnectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");

ConnectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");

ConnectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");

ConnectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "tblue");

ConnectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");



//Create a ServiceClientFactory object

ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);



//Create a TaskManager object

TaskManager myTaskManager = TaskManagerClientFactory.getTaskManager(myFactory);



//Get the XFA data to merge into the form

FileInputStream myData = new FileInputStream("C:\\Adobe\\FormData.xml");

Document doc = new Document(myData);

InputStream in = doc.getInputStream();

byte[] formarray = new byte[in.available()];

in.read(formarray);



//Retrieve the form instance associated with task 2

FormInstance newForm = myTaskManager.getEmptyForm();

newForm.setTemplatePath("C:\\Adobe\\Mortgage.xdp");

newForm.setXFAData(formarray);

newForm.setDocument(doc);



SaveTaskResult result = myTaskManager.save(2, newForm);

System.out.println("ActionFromData= "+result.getActionFromData());

System.out.println("task id= "+result.getTaskId());



}



catch(Exception e)

{

e.printStackTrace();

}

Avatar

Former Community Member
Another issue that you might have is that the user that you connect with:



ConnectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");

ConnectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");



must have the task that you are saving in their user queue. You cannot connect as an admin if the task you are trying to save is assigned to another user. This will cause an exception.

Avatar

Former Community Member
I have used ES API to kick off the process. The I have retrieved the created task id and do the TaskManager.save(). I didn't use Adobe workspacee.



The problem is, whether the task-status is 3(ASSIGNED), then it will throw the exception.



If the task-status is 1 or 2, it will update form data successfully.



I have tested the above scenario, its working fine.



Then, how can I update the form data if the status is assigned?



Thanks,

Saravanan

Avatar

Former Community Member
If a task is assigned to a specific user - you have to connect as that user in order to save the task. That is - in my example, the task was assigned to tony blue - notice that i connected as tony blue.



As far as how the process is kicked off - it should not matter whethet the process was started through the API or another invocation method.

Avatar

Former Community Member
Ok fine. Then How to save the form to db?



I have written the code for process kickoff using ES API.



Code:

----

Properties connectionProps = new Properties();

connectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");

connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");

connectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");

connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");

connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");



ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);



TaskManager task = TaskManagerClientFactory.getTaskManager(myFactory);



Map params = new HashMap();



InvocationRequest request = myFactory.createInvocationRequest

("<<my process name>>", //Specify the long-lived process name

"invoke", //Specify the operation name

params, //Specify input values

false); //Create an asynchronous request

InvocationResponse response = myServiceClient.invoke(request);

String invocationId = response.getInvocationId();



It successfully created the process id and task id. But not creating form instance id. I want to save the form data as Document or byte array to tb_form_data table.



How can I do that? Please provide the solution.



Thanks in advance.



Regards,

Saravanan

Avatar

Level 10
Like I said in anther post. Create yourself another process variable in the process you invoke and will contains the PDF. By creating a separate process variable it'll create a new database column with the content of the variable.



Jasmin

Avatar

Former Community Member
Another option that you can do is to create a component using Java JBDC APIs and develop that component so that it contains operations that can write to a database table. One of the powerful features of LiveCycle ES is its ability to enable you to create services that meet your requirements.



The SDK documentation describes how to create components.