How to use result variable from a task inside zeebe:input?

Hi folks!

I need to get the result from one task (its a custom connector created using Zeebe) and reference it i a field of another task, for example:

zeebe:input definition:

    {
      "label": "JSON Data",
      "group": "compose",
      "type": "Text",
      "binding": {
        "type": "zeebe:input",
        "name": "jsonServiceData"
      },
      "constraints": {
        "notEmpty": true
      },
      "description": ""
   }

and the value of the field (a json string)

{
    "Id": ${result.id}
}

${result.id} came from the previous task.

I dont know how to do this in the correct way

Someone can point the direction, please?

Hi!

Welcome to the forum!

I think you’re going to run into a LOT of trouble if you try to work on building templates before you’re really in depth into how the system actually works.

A Custom Template basically “automates” configuring a task step the same way every time.
First, figure out how to make the Service Task work on a BPMN level, before trying to package it up into a template.

A Zeebe:Input segment allows you to specify a field in the template (that the process designers will use, rather than the template author will use) to connect a process variable into a known step variable. This means that your process designers don’t need to remember if the field is called “idOrder” or “orderID” … if they use your template, they will have a space to specify the field in their process that contains the “Unique Order Number” and the template maps it to the step’s variables in the way the step wants it.

The community will probably help you create a template, if you can provide a basic-level BPMN diagram that works, and are able to articulate the things that the process designer should be able to change, and what the process designer should not be able to change.

From your post, you seem to be mixing the two roles:

  1. Template (and Connector) designer
  2. Process designer

Work with each role independently for a bit (I would recommend starting with the second one!) before trying to do both.

1 Like

Hi @hablocher, welcome to the forums! @GotnOGuts has it exactly right. The zeebe:input binding essentially defines a parameter that is sent down to the Connector Runtime+Service. Here’s a couple resources that I would recommend checking out. (Also, the syntax ${result.id} is not valid for Camunda 8. C8 uses FEEL.)

Hi @GotnOGuts and @nathan.loding! (please, forgive me for my bad english!)

Thanks a lot for your responses! I read these docs and helped me a lot, which i can use to implement a Connector (see below)

But i think i don´t explained very well my problem.

Lets define the scenario:

  1. I created an Outbound Connector using Connector SDK
  2. I created a template which define the input for this connector
  3. And use this template in Desktop Modeler.

Everything works fine! Deployed the process to Camunda, Started the process from Desktop Modeler and the connector receive and process sucessfully! Using IntelliJ and running inside a runtime i created in Quarkus!

But i need to send to my connector some value from process. For example, some variable created in Script Task. Or some result from other tasks!

I don’t know how to do this :slight_smile:

Because the context (which receive an instance of ActivatedJob) don´t have any way to query about process variables and their values.

My first attempt is, inside the template, read these values using some form of parser. But i think i got it wrong…

I suppose i need to use the Task Header, and use FEEL to set values to next task in the process (in Script Task, for example), but i dont know this is the right way

Can you guys help me to understand how to do this, please?

@hablocher - are you trying to send data to the Connector, or are you trying to do something with the data received from the Connector?

If sending, then you will use FEEL expressions on your input field. Let’s assume you have a process variable named userData. You would set the input field value to =userData. Also, in your Connector Template, you need to add the property "feel": "optional" (or "feel": "required" if you want to only accept FEEL expressions).

If receiving, then you would use a “result expression”. You can add a text area input to your Connector Template with the following binding, and it will make whatever you define within the result expression available in your process.

      "binding": {
        "type": "zeebe:taskHeader",
        "key": "resultExpression"
      },
1 Like

Hi @nathan.loding! :slight_smile: Thanks for your response!

I am trying to send data to Connector. For example, using the result from some task to extract some value and use this value to perform access to REST endpoints… and return the REST value as result of Connector… that is!

Worked!!! Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.