Hello,
I have designed the process as follows

In my html I have written code as follows
<adf-task-details
#activitidetails
[taskId]="currentTaskId"
(executeOutcome)="onExecuteOutcome($event)"
(formLoaded) = "onFormLoaded($event)"
(error)="customErrors($event)"
[showHeader]="false"
[showHeaderContent]="false"
[showInvolvePeople]="false"
[showComments]="false"
[showChecklist]="false"
[showFormTitle]="true"
[showFormCompleteButton]="true"
[showFormSaveButton]="false"
[showFormRefreshButton]="false"
[showNextTask]="true">
</adf-task-details>
In my typescript file of executeOutcome() i have written as follows
onFormLoaded(event) {
this.formOldValues = JSON.stringify(event.values);
this.formOldValues = JSON.parse(this.formOldValues);
}
onExecuteOutcome(event) {
if (event._outcome.name.toLowerCase() === "cancel") {
event.preventDefault();
this.cancelFormValues = new FormModel();
this.cancelFormValues = this.formOldValues;
this.formService
.completeTaskForm(this.currentTaskId, this.cancelFormValues, event._outcome.name)
.subscribe(
() => {
this.taskList.reload();
},
error => { alert(error); }
);
}
else {
event.preventDefault();
this.formService
.completeTaskForm(this.currentTaskId, event._outcome.form.values, event._outcome.name)
.subscribe(
data => {
this.taskList.reload();
},
error => {
let customErrors1 = JSON.parse(error);
let stringToSplit = customErrors1.exception;
if(stringToSplit == undefined){
this.snackBar.open(customErrors1.message, "ok", {
duration: 2500,
});
}
else {
let x = stringToSplit.split(":");
this.snackBar.open(x[2], "ok", {
duration: 2500,
});
}
}
);
}
}
After completing Task A, i will be navigated to Task B, when Task B is loaded this.formOldValues contains firstname and last name as blank. After filling the last name(this is required field), on click of cancel, the values must be blank and navigate to Task A but here i'm facing an error in console as follows

Here I have attached the my process design. Kindly anyone help me out regarding this.
Denys Vuika Maurizio Vitale
Thanks & Regards
Amruta Wandakar
What you are precisely asking is you want the task B to be cancelled using and outcome button called 'cancel' and the token should move back to task A.I see the following needs to be looked upon
1. If Task B has a form and if it has any mandatory fields then the cancel button will not be enabled due to form validator.
2. If you go for 'prevent default' for outcome button ,your token will remain in the same task i.e B.
3. With alfresco default behavior it tries to save the task form data on submit of any outcome button,which needs to be validated in case of mandatory fields.
This should be a generic UI requirement where there is a need to always enable cancel button with mandatory form fields .Please try to explore on unclaiming the task but i doubt if it moves back the token ..