5 Replies Latest reply on Apr 5, 2011 10:09 PM by $Nith$

    Searching task from API by process instance id

    hkho

      Hi, I am having problem retrieving tasks by process instance id throught API.

      I've look at the help, http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.html,

      it got sample code to retrieve tasks, it retrieve all tasks by process name, but I need to retrieve only tasks belong to a process instance id.

       

      how can i achieve this? any help is appreciated, thanks.

       

      hkho

        • 1. Re: Searching task from API by process instance id
          $Nith$ Level 4

          The following code may retrieve the tasks for a specific process instance.

           

          ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

          TaskManagerQueryService queryManager = TaskManagerClientFactory.getQueryManager(myFactory);


          TaskSearchFilter filter = new TaskSearchFilter();

          filter.setServiceName("MortgageLoan - Prebuilt");



          filter.addCondition("procVar.id", Operator.EQUALS, new Long(556677)); // where 556677 is your process Instance Id




          filter.setAdminIgnoreAllAcls(true);

          List result = queryManager.taskSearch(filter);

           

          Note:

            -> I dint test this code;

            -> You may have to make some corrections if its not working

            -> The code is based on Java API (Not Web Service)

           

           

          Nith

          1 person found this helpful
          • 2. Re: Searching task from API by process instance id
            hkho Level 1

            Thanks for the reply, I've tried the code and it throws an exception

             

            "com.adobe.idp.taskmanager.dsc.client.query.TaskQueryServiceException: Process Variable is not searchable. VariableName=id"

             

            I tried to add a new variable processId to the workflow and set the processId=id in the flow, then i filter by the processId and it works. But its a weird to duplicate the same same information in the process. Thanks.

            • 3. Re: Searching task from API by process instance id
              $Nith$ Level 4

              Alternate option:

               

              Do not add condition; rather just loop through the returned result and compare task task with its process id.

               

              List result = queryManager.taskSearch(filter);

               

              long myProcessId = 556677;

               

               

              for(int i=0;i<result.size();i++)

              {

              TaskRow myTask = (TaskRow)result.get(i);

               

              if(myTask.getProcessInstanceId()==myPorcessId)

              {

              // I found the tasks of myProcessId

              }

              }

               

               

              Nith

              1 person found this helpful
              • 4. Re: Searching task from API by process instance id
                avi_nyc

                Hi Nitin,

                My question is what is the difference between process and process instance? Can you please explain with an example? When I say process instance that means each process instance is unique because its initiator is different? or is there any other condition to differentiate between the processes?

                Thanks!

                • 5. Re: Searching task from API by process instance id
                  $Nith$ Level 4

                  You design a workflow to automate a Leave Request for your organization. This worflow is a process.

                  This process has no effect unless someone start a Leave Request. In otherwords just invoking the process and get the results out of it.

                   

                  Once a process is invoked, an instance (similar to how an object created for a class) will be created and executed within its own context.

                   

                  Each time when a user or another process invokes a process, a new process instance will be created.

                   

                  Each process instance is unique irrespective of the requester; i.e. If you request Leave for three time, it will create three unique process instances.

                   

                   

                  Nith