Get result one process instance camunda

I have a processed, valid customer. I want to get the result valid. what is the service task invalid?

Hey @Helen,
let me see whether I got your question right:
You have a running process instance containing a valid customer. But instead of executing the “yes” path you are running through the “no” one?

If that is the case you might want to check your expression in the exclusive gateway. :slight_smile:

Hi @Hafflgav,
Yes, I want to know to result of the process

Example: with the customer having cif= ‘1111’, the customer is 14 years old and invalid(year-old> 20).
when the process is complete, I want to get the result (cus not valid age in exclusive Gateway chekAge)

Hey @Helen!
I am very uncertain whether I understand what you exactly mean.

By clicking on the outgoing sequence flow of the exclusive gateway you can set a condition for instance ${age<20}. Keep in mind that this will only be valid if the variable age is an integer.

If you need to fetch the age based on an identifier (I guess that is what cif stands for?) you can either do so in a task before the gateway or by using a take-listener before the gateway.

If you want to check the variables you would typically take a look into cockpit where you can see what is going on. Or create a java delegate / external task which prints out all of the process variables.

Hopefully this helps… :slight_smile:

thank you @Hafflgav,
I want to know the result when the process complete

I have the history exclusive gateway by processInstanceId but I don’t know result is yes or no

Wouldn’t it be easier to log such kind of things? :thinking:
Besides you could do something like described in the picture below:

You just create an input in a following tasks which evaluates the same expression and saves it as a local variable which can be accessed even when the process is completed. :slight_smile:
This is just an example. You can add such a process variable nearly everywhere in the process.

Yes, I got the value of variable, but I want to know if it turns yes or no. I want to do it in code

image

That’s exactly what we are doing:
We are saving the value of the expression (e.g. yes or no) in the variable decision.
You can access this variable from code right after or when the process has finished.

how do i do it?
Can you give me the document?

I just found the REST Call you need in order to do so. But it should be feasible in Java code as well. I just do not have the time to try this out right now :frowning:

Here is a link to the REST API spec:
https://docs.camunda.org/rest/camunda-bpm-platform/7.19-SNAPSHOT/#tag/Historic-Variable-Instance/operation/getHistoricVariableInstances

To summarise:
Once you have saved the result of the expression as a variable in your BPMN model (as shown above). you can run the getHistoricVariableInstance query to retrieve it.

Yes, thank you @Hafflgav
It worked but want to know the result of checking the condition. Is it yes or no?

Yes, so what you need to do is:

  1. Take the expression from your condition
  2. Add an input to the subsequent user task
    • Add an input
    • Choose a variable name (e.g. condition-result)
    • Add the expression from your condition as value. This will be once again executed and the result of the condition is being added to the variable and saved in the process instance.
  3. Access the variables via the REST or JAVA API

When you do so it will tell you whether it is a “yes” or “no”.

Somehow I think we are talking about different things - but this is what I understood you wanted to do.
You need such kind of a workaround to access the result of the expression in a condition.

1 Like

thank you @Hafflgav ,
I don’t want to interfere with bmnp file, but I want with variable it is valid or invalid

Puh that sounds tough… I’ve seen you asking in another thread as well.
I do not have another idea than that what @jonathan.lukas and @Ingo_Richtsmeier said… :frowning:

Hello @Helen ,

if you want to know the value without manipulating the BPMN file, you could do the following:

  • parse the file to get the expression from the sequence flow
  • read all variables from the history
  • use the ExpressionManager from the engine
  • evaluate the expression from the sequence flow against the context you create from the process variables

However, the way @Hafflgav described is much easier and cleaner as the result of your expression is saved as process variable and only evaluated as atomic value.

This makes the process much more transparent during runtime.

Jonathan

1 Like

Thank you @jonathan.lukas,
what is the ExpressionManager ? I dont know it. how do my project use?

Hello @Helen ,

the ExpressionManager is part of the process engine and can be retrieved from its configuration.

I ask you again to use the way @Hafflgav suggested, even if this would require changes in the process diagram.

Jonathan

1 Like