cancel
Showing results for 
Search instead for 
Did you mean: 

TaskService.complete vs. FormService.submitTaskFormData

limcheekin
Champ on-the-rise
Champ on-the-rise
Hi,

TaskService.complete(taskId, variables) vs. FormService.submitTaskFormData(taskId, properties), what is the different? When should I use TaskService.complete or FormService.submitTaskFormData? I am confuse.

Please advice. Thanks.

Regards,
Chee Kin
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
The taksService.complete(…) just completes the task and sets the given variables. The formService.submitTaskFormData works a bit different, it submits form properties instead of variables. These properties won't always map one on one with variables. Some post-processing can be done (for example calculate a value based on values filled in on the form, and use the result as a process-variable instead).

Check out http://activiti.org/userguide/index.html#externalFormRendering for a more detailed description of the new form-handling mechanism.

limcheekin
Champ on-the-rise
Champ on-the-rise
Check out http://activiti.org/userguide/index.html#externalFormRendering for a more detailed description of the new form-handling mechanism.

Thanks for writing. Yes, I did gone through that section before I post this topic. But your explanation and the User Guide doesn't show how we should use TaskService.complete or FormService.submitTaskFormData (Maybe just I don't get it), please give some sample codes to illustrate it.

Thanks,
Chee Kin

limcheekin
Champ on-the-rise
Champ on-the-rise
I think the answer is in Form properties section, FormService.submitTaskFormData it is more for declarative form properties in process definition. But in runtime, both TaskService.complete and FormService.submitTaskFormData behave the same, am I right?

Chee Kin

frederikherema1
Star Contributor
Star Contributor
The submitTaskFormData will do post-processing based on the properties that are passed. For example, some submitted properties will be set as variables, other will be used to calculate other variables that will be set. The properties passed in the submitTaskFormData should be the ones declared in the FormData (accuired by getFormInstance()). Test for this is in the examples:
org.activiti.engine.test.forms.FormsTest
The taskService.complete(taskId, variables) doesn't take the form-property declarations into account and just sets the variable values as they are passed and completes the task. This can be used when no task form is used, but programmatic input is needed (can't think of a concrete example right now).

limcheekin
Champ on-the-rise
Champ on-the-rise
Thanks for further explanation and point out an example: org.activiti.engine.test.forms.FormsTest. I think I get it.

Regards,
Chee Kin

limcheekin
Champ on-the-rise
Champ on-the-rise
Hi there,

In History for audit purposes section of User Guide at http://activiti.org/userguide/index.html#historyFormAuditPurposes, it mentioned:
When configuring at least audit level for configuration. Then all properties submitted through methods FormService.submitStartFormData(String processDefinitionId, Map<String, String> properties) and FormService.submitTaskFormData(String taskId, Map<String, String> properties) are recorded.

How about TaskService.complete? Will data submit via TaskService.complete be recorded?

Thanks,
Chee Kin

tombaeyens
Champ in-the-making
Champ in-the-making
How about TaskService.complete? Will data submit via TaskService.complete be recorded?

Nope.  Only when you use FormService.submitTaskForm the form properties will be recorded.

The TaskService.complete is on the variables level.  In the task service complete, there is no mapping between form properties and process variable as there is with the form service methods.

limcheekin
Champ on-the-rise
Champ on-the-rise
Noted. Thanks.

Regards,
Chee Kin
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.