Custom Script on Workflow action


I want to execute a script when the user approves a (workflow)request.

User submitted a form… now the state is pending
Admin approves it and on approval/rejection I want to execute a custom script to send a notification mail

You don’t need custom script for notification mail. Set up a custom alert in Notification to automatically send a mail to desired recipients when the document status changes to Submitted.

thanks for the reply.
can you please explain in detail with an example or screen shot?


Sample Notification for Purchase Order:

Go to Settings->Notifications->New

Enter desired subject, select doctype and select Send Alert On (to determine when exactly the notification will be sent:

Specify the recipients, either email by role or document field and determine the body of the mail. Once you are sure all details are complete, save and submit the alert.

This notification will be sentfor the doctype everytime the action specified (such as submit) is triggered.

Thanks. working!

1 Like

but is there any way to execute a custom script on state change?
apart from email if I want to perform some other action is that possible?

You can set up multiple notifications for each state change. But by default, workflow has built-in notifications for every state change except on submit.

If the highlighted box is checked, everytime there is a change in workflow state, an alert is sent to the role assigned to the new state.