cancel
Showing results for 
Search instead for 
Did you mean: 

unable to get Task after a condition

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Hello

I know i made a mistake somewhere. Please guide me.

I have a bpmn file.

        <process id="usecase_indexer_createwidget" name="Indexer Usecase">
        <startEvent id="StartNoneEvent_2" activiti:form="org/activiti/examples/task/search_document.form"/>
        <task name="Search Document on First Name, Last Name, SSN" id="searchdoc_on_fn_ln"/>
        <task name="Push to Allocate" id="push_to_allocate"/>
        <task name="Append Document to Existing Widget" id="append_doc_to_existing_widget"/>
        <task name="Create Widget with FN, LN, SSN, and Networth as IndexFields"
        activiti:form="org/activiti/examples/task/create_widget.form"
        id="create_widget"/>
        <exclusiveGateway gatewayDirection="Diverging" name="Document Exists?" id="is_document_existing"/>
        <sequenceFlow targetRef="searchdoc_on_fn_ln" sourceRef="StartNoneEvent_2" id="SequenceFlow_3"/>
        <sequenceFlow targetRef="is_document_existing" sourceRef="searchdoc_on_fn_ln" id="SequenceFlow_1"/>
        <sequenceFlow targetRef="append_doc_to_existing_widget" sourceRef="is_document_existing" id="SequenceFlow_2">
            <conditionExpression xsi:type="tFormalExpression" >${doc_found}</conditionExpression>
        </sequenceFlow>
        <sequenceFlow targetRef="create_widget" sourceRef="is_document_existing" id="SequenceFlow_4">
            <conditionExpression xsi:type="tFormalExpression" >${!doc_found}</conditionExpression>
        </sequenceFlow>
        <sequenceFlow targetRef="push_to_allocate" sourceRef="append_doc_to_existing_widget" id="SequenceFlow_5"/>
        <sequenceFlow targetRef="push_to_allocate" sourceRef="create_widget" id="SequenceFlow"/>
    </process>
</definitions>

and java code for the above process
    // Get start form
    Object startForm = taskService.getRenderedStartFormByKey("usecase_indexer_createwidget");
    assertNotNull(startForm);
   
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertEquals("org/activiti/examples/task/search_document.form", processDefinition.getStartFormResourceKey());
    System.out.println("Start search form … "+ startForm);
    // Define variables that would be filled in through the form
    Map<String, Object> variables = new HashMap<String, Object>();
    String fname = "app_fn";
    String lname="app_ln";

    variables.put("firstName", fname);
    variables.put("lastName", lname);
    variables.put("doc_found", Boolean.FALSE);
   
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("usecase_indexer_createwidget", variables);

//List<Task> tasks = query.list();
    System.out.println("List of Tasks  "+taskService.createTaskQuery()
           .processInstanceId(pi.getId()).list());

I was expecting "create_widget" task. but it shows none.

Please guide me where is my mistake

Thank you
8 REPLIES 8

jcosano
Champ in-the-making
Champ in-the-making
can you try to replace "task" by "userTask" in your model??

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Thank you so much for a quick reply.

Yes it works with userTask. but it returns the first task "searchdoc_on_fn_ln". I was expecting "create_widget" task to be returned. What's wrong in the logic?

Thank you again

jcosano
Champ in-the-making
Champ in-the-making
The first task that you define is: "searchdoc_on_fn_ln" (after start) then…  process is waitting this task to be completed.

If you removed this task… and join "start" with the gateway then you obtain your expected value.

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Thanks much….  Smiley Very Happy

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
why wasn't "task" working? Do I always create a userTask in the model ?

jcosano
Champ in-the-making
Champ in-the-making
What is task?

manualTask? userTask? serviceTask ???

Each "task" has its own behaviour…  and you need to specify what behaviour you need, using proper tag.

Then, you don't need to use always "userTask", there are other controlled tags (look at http://activiti.org/userguide/index.html#bpmnConstructs )

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
Right!

Thanks much… my demo will be ready soon!

jbarrez
Star Contributor
Star Contributor
Exactly. In BPMN 2.0, a 'task' without any further specification is often used by process modelers to model a 'I don't yet know'. As such, for the engine a 'task' acts as a noop or passthrough for the engine.