Skip to content

Commit 712881e

Browse files
Form instance by id test + fix
1 parent 6789334 commit 712881e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

modules/flowable-form-engine/src/main/java/org/flowable/form/engine/impl/cmd/GetFormInstanceModelCmd.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ protected FormInstance resolveFormInstance(CommandContext commandContext) {
242242
}
243243

244244
FormInstance formInstance = null;
245-
if (taskId != null) {
245+
if (formInstanceId != null) {
246+
formInstance = formInstances.get(0);
247+
248+
} else if (taskId != null) {
246249
if (formInstances.size() > 1) {
247250
throw new FlowableException("Multiple form instances are found for the same task");
248251
}

modules/flowable-form-engine/src/test/java/org/flowable/form/engine/test/FormInstanceTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.Map;
1919

2020
import org.flowable.form.api.FormInstance;
21+
import org.flowable.form.model.FormField;
22+
import org.flowable.form.model.FormInstanceModel;
2123
import org.flowable.form.model.FormModel;
2224
import org.joda.time.LocalDate;
2325
import org.junit.Test;
@@ -41,6 +43,13 @@ public void submitSimpleForm() throws Exception {
4143
JsonNode formNode = formEngineConfiguration.getObjectMapper().readTree(formInstance.getFormValueBytes());
4244
assertEquals("test", formNode.get("values").get("input1").asText());
4345
assertEquals("default", formNode.get("flowable_form_outcome").asText());
46+
47+
FormInstanceModel formInstanceModel = formService.getFormInstanceModelById(formInstance.getId(), null);
48+
assertEquals("form1", formInstanceModel.getKey());
49+
assertEquals(1, formInstanceModel.getFields().size());
50+
FormField formField = formInstanceModel.getFields().get(0);
51+
assertEquals("input1", formField.getId());
52+
assertEquals("test", formField.getValue());
4453
}
4554

4655
@Test

0 commit comments

Comments
 (0)