Getting Process Form Data
The io.jmix.bpm.processform.ProcessFormDataExtractor bean provides programmatic access to process-form information. The following example demonstrates a REST controller that uses this bean to obtain the form data associated with a running process instance.
@RestController
@RequestMapping("rest/bpm/process-form-data")
public class FormDataController {
@Autowired
private ProcessFormDataExtractor processFormDataExtractor;
@GetMapping(produces = "application/json")
public FormData getTaskFormData(
@RequestParam(required = false) String taskId,
@RequestParam(required = false) String processDefinitionId) {
if (Strings.isEmpty(taskId) && Strings.isEmpty(processDefinitionId)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The taskId or processDefinitionId parameter has to be provided");
}
if (!Strings.isEmpty(taskId) && !Strings.isEmpty(processDefinitionId)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The request cannot contain both taskId and processDefinitionId.");
}
if (Strings.isEmpty(taskId)) {
return processFormDataExtractor.getStartFormData(processDefinitionId); (1)
} else {
return processFormDataExtractor.getTaskFormData(taskId); (2)
}
}
}
| 1 | Supplying a processDefinitionID returns the data for the process’s start form. |
| 2 | Supplying a taskID returns the data for that task’s form. |
Success response body:
{
"type": "jmix-screen",
"screenId": "FormExample",
"openMode": "DIALOG",
"businessKey": null,
"businessKeySource": null,
"allowedProcessKeys": [],
"fields": [],
"outcomes": [],
"formParams": [],
"outputVariables": []
}
| Make sure to secure application endpoints. Use the code samples in Custom Endpoints as a guide. |
Was this page helpful?
Thank you for your feedback