I have a requirement to have strict validation of form properties (i.e) activiti should only save the exact form properties that are defined as part of extension elements under a user task.
Assume I have a userTask with some form properties attached.
<userTask id="usertask1" name="Submit Form">
<extensionElements>
<activiti:formProperty id="name" name="Name" type="string" variable="name" required="true"></activiti:formProperty>
<activiti:formProperty id="age" name="Age" type="string" variable="age" required="true"></activiti:formProperty>
</extensionElements>
</userTask>
On POST, I build the variables from the request and invoke the below line of code to save the values and complete the task.
formService.submitTaskFormData(taskId, variables);
If I don't pass any of the defined properties, the system spits out an exception stating "form property ..... is required". This is good. My issue is if I pass in any additional value as a form property like 'address', activiti accepts it and saves it.
Is it possible for me to tell activiti to accept only the two properties that are defined and throw an exception if any additional properties are sent in? If there is no straightforward solution to it, what is best way for me handle/validate this?
I think it would be possible for you to write code that would retrieve the extension elements and then validate that the variables are only for these elements (assuming you do have to look these up at runtime and have to get them from the definition). There is code which looks up elements in this way in this post - How to get a custom properties from UserTask
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.