Validation Error in custom outcome

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Senior Member

Validation Error in custom outcome

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

formOldValues: any;
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 VuikaMaurizio Vitale

Thanks & Regards

Amruta Wandakar

4 Replies
Highlighted
Member II

Re: Validation Error in custom outcome

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 ..

Highlighted
Alfresco Employee

Re: Validation Error in custom outcome

I'm not sure if I understand why you are doing in the code something that APS workflow should be responsible for? You could bring variables from stage to stage if needed, without hacking the form and outcome buttons.

Are you sure it is absolutely necessary do that in javascript?

Highlighted
Senior Member

Re: Validation Error in custom outcome

Denys Vuika‌ yes. Onclick of cancel it should cancel that task and erase the entered data then move back to previous task, while doing this from the backend i'm getting that error. So how can I resolve this?

Highlighted
Active Member II

Re: Validation Error in custom outcome

Are you doing something similar to this?