Camunda Performance

Hi Everyone,

This is regarding a query, if I am maintaining hundreds of variables at process level, will it effect anyway in performance.(as in - execution of the process | delay in loading the process or tasks in cockpit or task list ).

I am maintaining this number of variables because I have to auto populate the fields in the embedded forms configured inside the user task.

@WilliamR.Alves , @jonathan.lukas , @StephanHaarmann , @jwulf
Suggestion of new ideas or approaches are highly appreciated.

Hello, my dear! \o

In fact, keeping too many variables can compromise performance.

One thing that can be done, for example, is… when receiving an API return, use SpinJson to work with the JSON object and then access its properties one by one through the “.prop()” method.

Imagine that you made a call to a “Registration” API, and received a response in which you would save each response data in a process variable, for example “name”, age.

Instead of saving it in separate variables, you would output a single response variable for this API, for example “registrationResponse”, which would return a complete JSON object.

For this you must put in the “Connector Output” this:
In the “Process variable name” field: registrationResponse
${S(response)}

And in the registrationResponse variable you received the following JSON below for example:

{
   "data":{
      "process":{
         "variables":[
            {
               "name":"William",
               "age": 33
            }
         ]
      }
   },
   "result":{
      "code":"200",
      "info":"OK"
   }
}

So if somewhere else in your project you need access to variables you’ll do this:

var name = registrationResponse.prop("data").prop("process").prop("variables").prop("name").stringValue();

and then you will already have the value of “name” only within that scope and not as a new process variable, as the value will be within a single variable that will be your registrationResponse.

I don’t know if I understood your question correctly, but I think that’s it.
If not, you can contact us again :smiley:

Cya.
William Robert Alves

1 Like

Hi @Buddhi_Sagar_Tiwari,

This old incomplete series might be of help to you.

1 Like

Hi @WilliamR.Alves ,

Thanks a lot for responding …

i undertsand your whole point , but can i ask , how can i do… if i want to auto populate name fields or other fields in embedded forms using script tag ,that is present inside the registration response object ?

I know i can’t use cam-variable-name , that is not for complex objects! correct me if i am wrong.

Hope i have delivered my thoughts clearly.

Hello my friend! :smiley:
Honestly I haven’t used many forms in my life hehehe, but come on…

I believe you can do this:

In the “Default value” field, try to put that expression that I sent you in my previous message as in the image below:

I believe it works.
image

Another thing you could do is, put your form activity inside an expanded subprocess, passing as “In mapping” the JSON variable that contains all the data you need, and inside this process in the “start event” you use the execution listner to transform all the data you need from this JSON into a process variable of this scope.

Imagine that you mapped into this subprocess where your form is, the JSON variable called “registrationResponse” and inside it you have the properties I mentioned earlier. You must do the following:

var name = registrationResponse.prop("data").prop("process").prop("variables").prop("name").stringValue();

var age = registrationResponse.prop("data").prop("process").prop("variables").prop("age").numberValue();

execution.setVariable("name", name);
execution.setVariable("age", age);

And then you’ll create the process variables each you need with the correct name by accessing the JSON variable values that you mapped into the subprocess with your Form.

And so you can use the expression ${name} and ${age} within the “Default value”.

And so that the variables don’t get “dirty” your process, just don’t map them in the outmapping, because that way they will only be in this scope.

If someone who works more with forms, knows a better way to do it to give a suggestion to our friend… it will be very welcome!

I hope this helps brother! :smiley:

William Robert Alves

1 Like