AnsweredAssumed Answered

External form rendering : Form properties values listing

Question asked by fredg on Aug 9, 2011
Latest reply on Apr 2, 2014 by james_eckles@cable.comcast.com
Hi all,

I’m working on a workaround to migrate from jpdl outgoing transitions to BPMN 2 (human task + Exclusive gateway)

My need:

* Provide a form display; give user a choice to decide next step (outgoing sequence flow).
* Choice must be "by design" embedded in process. (using Activiti Eclipse Designer)

Reading this forum I saw that the way to do is using a process like this: a usertask followed by an exclusive gateway.


My solution:

* UserTask : add some form properties, and use them for the following Exclusive gateway evaluation.
Example:

    <formProperties id="step1" name=" step1" type="enum" value="TaskA,TaskB" readable="true" />
    <formProperties id="step2" name=" step2" type="string" value="TaskA,TaskB" readable="true" />
* List those values using List<FormProperty> formService.getTaskFormData(task.getId()).getFormProperties()

Unfortunately, List<FormProperty> is always empty and I can't get any of them, so I’m unable to provide my user a choice.


I would like to access a form property default value, in my case "TaskA,TaskB"
The user choice (TaskA or TaskB) with then be added to a variable so the gateway can take a decision.

Can someone explain why FormProperty.getValue() is always null ?


Activiti 5.6, postgres 9, spring 3.x

Here is code :


   ProcessInstance processInstance = null;
        try {
            /**
             * You must define "initiator" on StartEvent node
             * FIXME Thead safe ?
             */
            this.identityService.setAuthenticatedUserId("ofred");
            processInstance = this.runtimeService.startProcessInstanceByKey("testGateway",
                            null,
                            new HashMap<String, Object>());
        } finally {
            this.identityService.setAuthenticatedUserId(null);
        }
        assertFalse(processInstance.isEnded());
        //Step 1 : we should wait on usertask1
        Task task = this.taskService.createTaskQuery()
            .processInstanceId(processInstance.getId())
            .singleResult();
        assertEquals("User Task", task.getName());
        //FORM
        Object o = this.formService.getRenderedTaskForm(task.getId());
        assertNull(o);
        /**
         * Get list of available user choice : pseudo out going transitions
         * Process definition must be readable="true"
         * ENUM types not yet supported see http://jira.codehaus.org/browse/ACT-882 as java enum (and sucks in designer)
         */
        StartFormData startformData = this.formService.getStartFormData(processInstance.getProcessDefinitionId());
        assertNotNull(startformData);
        assertEquals(0, startformData.getFormProperties().size());
        /**
         * Only readable="true" will be visible
         */
        TaskFormData formData = this.formService.getTaskFormData(task.getId());
        List<FormProperty> data = formData.getFormProperties();
        assertNotNull(data);
        assertTrue(data.size() > 0);//FIXME fails !!
        for (FormProperty prop : data) {
            String id = prop.getId();
            String value = prop.getValue();
        }

Outcomes