2 Replies Latest reply on Jun 17, 2014 5:29 AM by Anindya Saha

    API to query process instances by variable

    Hugues Bernard Newbie

      Is it possible, using the JAVA API, to query process instances by variable ?

      Imagine I started many processes instances with variable "foo" initialized with some instance specific value.  The process instances are pedning some user interaction.

      What is the best way using the API to query all pending process instances with a search criteria such as "where variable foo has value xyz" ?

      Thanks a lot.

        • 1. Re: API to query process instances by variable
          Maciej Swiderski Master

          take a look at AuditLogService which might be useful for your case. Here is the default implementation which you need to use to get data from data base.



          • 2. Re: API to query process instances by variable
            Anindya Saha Newbie

            As Maciej pointed out check the public List<VariableInstanceLog> findVariableInstancesByNameAndValue(String variableId, String value, boolean onlyActiveProcesses) in JPAAuditLogService


            Here you have to just tweak this query to return ProcessInstanceLog instead of VariableInstanceLog

            query = em.createQuery(

                                "SELECT v "

                                + "FROM VariableInstanceLog v, ProcessInstanceLog p "

                                + "WHERE v.processInstanceId = p.processInstanceId "

                                + "AND v.variableId = :variableId "

                                + "AND v.value = :value "

                                + "AND p.end is null "

                                + "ORDER BY v.date");