Service Task with HTTP REST connector outgoing parameter not getting parsed at Exclusive gateway

Hi,

I have a Service Task with HTTP REST connector. I parsed the response of the HTTP REST using script task and set to connector outgoing parameter.
My goal is to pass that outgoing parameter to validate the condition ${lineStatus == ‘OK’} at Exclusive gateway. But am getting below exception,

[http-nio-8080-exec-10] org.camunda.bpm.engine.rest.exception.RestExceptionHandler.toResponse org.camunda.bpm.engine.rest.exception.RestException: Cannot instantiate process definition CallForwardUsecase:8:7ff2c878-9153-11e7-b400-5cc5d4a39918: ENGINE-02004 No outgoing sequence flow for the element with id 'ExclusiveGateway_1' could be selected for continuing the process.
	at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.submitForm(ProcessDefinitionR

My BPMN file:

Service task connector:

<camunda:outputParameter name="lineStatus">
  <camunda:script scriptFormat="Javascript"><![CDATA[S(response).prop("status")]]></camunda:script>
</camunda:outputParameter>

Exclusive gateway:

<bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="isPhoneAvailable?">
      <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:sequenceFlow id="SequenceFlow_5" name="yes" sourceRef="ExclusiveGateway_1" targetRef="ServiceTask_3">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${lineStatus == 'OK'}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_7" name="no" sourceRef="ExclusiveGateway_1" targetRef="UserTask_1">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${lineStatus == 'OKkk'}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>

Hi,

the exception states that both expressions are false. So the lineStatus is neither OK nor OKkk, I would expect that the lineStatus is not OKkk if something went wrong? Did you check if the variable is set to another value or is it empty?

Cheers,
Sebastian

Hi Sebastian,

Its working fine now after making changes In my JS file.

  • I did convert my response key to StringValue() and
  • set the lineStatus to true/false.
  • Condition is ${lineStatus}

var status = api_response.prop(“status”).stringValue();
var status = api_response.prop(“status”).stringValue();
log.info("Status: "+ status);

if(status == “OK”){
var s = true;
log.info("If block s: "+ s);

}
else {
var s = false;
log.info("s***: "+ s);
}

Again facing an issue,

05-Sep-2017 16:16:22.003 SEVERE [http-nio-8080-exec-40] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: condition expression returns null: result is null
org.camunda.bpm.engine.exception.NullValueException: condition expression returns null: result is null

BPM Source:

   <bpmn2:serviceTask id="ServiceTask_2" name="PhoneStatus">
  <bpmn2:extensionElements>
    <camunda:connector>
      <camunda:connectorId>http-connector</camunda:connectorId>
      <camunda:inputOutput>
        <camunda:inputParameter name="url">http://${application.phoneIP}/cgi-bin/api-get_phone_status?passcode=admin</camunda:inputParameter>
        <camunda:inputParameter name="method"><![CDATA[
          GET
        ]]></camunda:inputParameter>
        <camunda:inputParameter name="headers">
          <camunda:map>
            <camunda:entry key="Accept"><![CDATA[
              application/json
            ]]></camunda:entry>
          </camunda:map>
        </camunda:inputParameter>
        <camunda:outputParameter name="phoneStatus">
          <camunda:script scriptFormat="Javascript" resource="phoneStatus.js"/>
        </camunda:outputParameter>
      </camunda:inputOutput>
    </camunda:connector>
  </bpmn2:extensionElements>
  <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
  <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
  <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="ServiceTask_1" targetRef="ServiceTask_2"/>
<bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="ServiceTask_2" targetRef="ExclusiveGateway_1"/>
<bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="isPhoneAvailable?">
  <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
  <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing>
  <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_5" name="yes" sourceRef="ExclusiveGateway_1" targetRef="ServiceTask_3">
  <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${phoneStatus}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="SequenceFlow_7" name="no" sourceRef="ExclusiveGateway_1" targetRef="UserTask_1">
  <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${!phoneStatus}</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>

JS File:

//parse response variable with camunda-spin
var api_response = S(response);

var status = api_response.prop(“body”).stringValue();
log.info("Status: "+ status);

if(status == “available”){
var s = true;
log.info("If block s: "+ s);

}
else {
var s = false;
log.info("s***: "+ s);
}
connector.setVariable(“phoneStatus”, s);

I think your script has to return something which is then saved as the variable phoneStatus defined in the XML. So instead of connector.setVariable("phoneStatus", s); use something like s; instead.

Thanks. I will try this.

I have another question about timer event, i have attached a Intermediate Catch event with timer PT10S but the timer event takes more than 50sec. I do not know why it is taking more time than specified. how to overcome this issue?