How to implement autosave for Alfresco Process Service forms

You just need to subscribe to formFieldValueChanged, and save the form using formService.saveTaskForm whenever there is a change on the form values.

Important Note: Make sure you unsubscribe from autosave subscription onDestroy, to avoid messing and overriding previous accessed forms/tasks.

import {FormEvent, FormService} from "@alfresco/adf-core";
import {debounceTime} from "rxjs/operators";
import {Component, Input} from "@angular/core";

@Component({template: ''})
export abstract class FormApsAbstractComponent implements OnDestroy {
  @Input() taskId: string;
  autoSaveSubscription: Subscription;

  constructor(public formService: FormService) {

  enableAutoSave() {
    this.autoSaveSubscription = this.formService.formFieldValueChanged
      .subscribe((e: FormEvent) => {      
      	this.formService.saveTaskForm(this.taskId, e.form.values);
  abstract ngOnDestroy(); // make sure any component that extends this abstract component gets unsubscribed from autoSave subscription