Good afternoon Camunda,
I would like to build templates with predefined fields.
I created service task (implementation Connector) configured details in Connector tab
And now I would like to move my configuration to template and achieve the same behavior.
My schema look’s like that
First sevice task it is a connector which have to fetch some data from test api and put response into variable.
And it works fine, I could take the result from variable in the next service tasks which is external.
(process instance variables tab contains response)
My connector service task in xml view looks:
<bpmn:serviceTask id="Activity_0iger68">
<bpmn:extensionElements>
<camunda:connector>
<camunda:inputOutput>
<camunda:inputParameter name="url">http://dummy.restapiexample.com/api/v1/employee/1</camunda:inputParameter>
<camunda:inputParameter name="method">GET</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map />
</camunda:inputParameter>
<camunda:outputParameter name="response">
<camunda:script scriptFormat="JavaScript">S(response).prop("data")</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1y9smk0</bpmn:incoming>
<bpmn:outgoing>Flow_0jwf2sp</bpmn:outgoing>
</bpmn:serviceTask>
Then I tried to move all this input and output params to element template:
[
{
"name": "Get weather data",
"id": "my.connector.http.get.weather",
"appliesTo": [
"bpmn:Task"
],
"properties": [],
"scopes": {
"camunda:Connector": {
"properties": [
{
"label": "ConnectorId",
"type": "String",
"value": "http-connector",
"binding": {
"type": "property",
"name": "connectorId"
}
},
{
"label": "Method",
"type": "String",
"value": "GET",
"binding": {
"type": "camunda:inputParameter",
"name": "method"
}
},
{
"label": "URL",
"type": "String",
"value": "http://dummy.restapiexample.com/api/v1/employee/1",
"binding": {
"type": "camunda:inputParameter",
"name": "url"
}
},
{
"label": "Response",
"type": "String",
"value": "response",
"binding": {
"type": "camunda:outputParameter",
"source": "S(response).prop(\"data\")",
"scriptFormat": "JavaScript"
}
}
]
}
}
}
]
There is no map but as I red there is workaround for it Camunda Modeler template with Connector Scope - Defining headers - #3 by andreasmartin
Which I also tried
So my element in xml view looks:
<bpmn:task id="Activity_1u5gfs8" camunda:modelerTemplate="my.connector.http.get.weather">
<bpmn:extensionElements>
<camunda:connector inout="">
<camunda:inputOutput>
<camunda:inputParameter name="method">GET</camunda:inputParameter>
<camunda:inputParameter name="url">http://dummy.restapiexample.com/api/v1/employee/1</camunda:inputParameter>
<camunda:outputParameter name="response">
<camunda:script scriptFormat="JavaScript">S(response).prop("data")</camunda:script>
</camunda:outputParameter>
</camunda:inputOutput>
<camunda:connectorId>http-connector</camunda:connectorId>
</camunda:connector>
</bpmn:extensionElements>
<bpmn:incoming>Flow_13wi79n</bpmn:incoming>
<bpmn:outgoing>Flow_0cobpk4</bpmn:outgoing>
</bpmn:task>
But in this implementation I don’t have response variable in next service task (process instance variables tab is empty)
Is it possible to move all configs not only for connector but in general with other elements
to template
If yes what I am doing wrong?
Thanks in advance
Kr,
Mark
Working Solution
[
{
"name": "Get weather data",
"id": "my.connector.http.get.weather",
"appliesTo": [
"bpmn:ServiceTask"
],
"properties": [],
"scopes": {
"camunda:Connector": {
"properties": [
{
"label": "ConnectorId",
"type": "String",
"value": "http-connector",
"binding": {
"type": "property",
"name": "connectorId"
}
},
{
"label": "Method",
"type": "String",
"value": "GET",
"binding": {
"type": "camunda:inputParameter",
"name": "method"
}
},
{
"label": "URL",
"type": "String",
"value": "http://dummy.restapiexample.com/api/v1/employee/1",
"binding": {
"type": "camunda:inputParameter",
"name": "url"
}
},
{
"label": "Response",
"type": "String",
"value": "response",
"binding": {
"type": "camunda:outputParameter",
"source": "S(response).prop('data')",
"scriptFormat": "JavaScript"
}
}
]
}
}
}
]