Fetch Workflow activity log in print format

I’m using ERPNext v12, and I need to fetch the workflow history (workflow state + user who performed the action) in a Jinja Print Format** for my Delivery Note.

I got the solution through below jinja code.

{% set pickup_comment = frappe.get_all(“Comment”,
filters={
“reference_doctype”: “doctype”,
“reference_name”: doc.name,
“comment_type”: “Workflow”,
“content”: “workflow_state”
},
fields=[“name”], limit_page_length=1)
%}