Workflow email notification template with workflow-action link

I’m a new ERPNext user and I am trying to figure out to get the desired behavior for an approval loop for, lets say, a purchase order. I’ve defined the workflow with the desired states and transitions and this works fine. I know there is the option to select the “Send Email Alert” to send and email alert with available options for progressing to the next state, but this is send to all users that have permissions to do so and this is not what I want.

I found that an alternative option is to use a notification on a state-change in wich its easier to define who gets a certain notification. This works fine, but theres a catch because I lose the nice buttons to Approve or Decline directly in the email. I am trying to reproduce this but no succes so far.

After digging in the code I see there are some functions to generate these action links, such as “get_workflow_action_url” in workflow_actions.py

def get_workflow_action_url(action, doc, user):
	apply_action_method = "/api/method/frappe.workflow.doctype.workflow_action.workflow_action.apply_action"

params = {
	"doctype": doc.get('doctype'),
	"docname": doc.get('name'),
	"action": action,
	"current_state": get_doc_workflow_state(doc),
	"user": user,
	"last_modified": doc.get('modified')
}

return get_url(apply_action_method + "?" + get_signed_params(params))

However, I’m not sure IF and how to call this function from my notification template. Passing the action (hardcoded), user and document seems not impossible and it seems that frappe.call could be an option, but here I’m stuck…

Alternatively, if there would be an option to use the default template but limit who would get the email this could also work…

1 Like

Any suggestion on how to solve this issue? For now I’ve simply accepted that this link is not available in the email, but I cant imagine I am the only one facing this?

Hey were you able to resolve it?

any update?