Athira S Raj
Athira S Raj

Reputation: 212

Creating a form with workflow one step approval

Created a form with button actions 'Approved' and 'Rejected' and selected workflow 'One step approval'.But after approving/rejecting the form status is still shown as 'New'.Is there anything missing from my side

Upvotes: 1

Views: 120

Answers (1)

crystalthinker
crystalthinker

Reputation: 1182

You missed adding custom code for updating the action Type at the form Design. just adding the button from form design for update the Application Status . You need to define when to emit the customEvent with actionComplete Type example use the below for approved.

form.emit('customEvent', {
              type: "actionComplete",   
              component: component,
              actionType: "Approved" // action Type you need to pass
        }); 

Click here to know more custom Events Available

Find a sample code from the Freedom of Information form given as a sample below which does a similar behaviour : enter image description here enter image description here

    const submissionId = form._submission._id;
const formDataReqUrl = form.formio.formUrl+'/submission/'+submissionId;const formDataReqObj1 =  {  "_id": submissionId,  "data": data};
const formio = new Formio(formDataReqUrl);
formio.saveSubmission(formDataReqObj1).then( result => {
form.emit('customEvent', {
          type: "actionComplete",   
          component: component,
          actionType: "data.actionType" // action Type you need to pass
    }); 
}).catch((error)=>{
//Error callback on not Save
});

You need to choose custom Action on the button as shown:

enter image description here

Upvotes: 0

Related Questions