Attach pdf to notification email

Hi, I have a workflow that puts a button on the Sales Invoice form. The button submits the Sales Invoice and an email Notification fires. I’m a Cloud User and recently upgraded to the latest version. In the past, submitting the Sales Invoice Form would initiate the email sending with a termloate that I could change to include the PDF. This usually worked (except when I forgot to select the check-box); now, I just get the Notification, which is better really, as it gets sent without any further intervention from me (except then I don’t have the option of attaching the PDF).

Is there a way of automatically attaching the PDF to the notification email? I have a bit of HTML/Jinja that attaches a link to the PDF, but I need to attach the actual file, because it’s going to someone who isn’t able to link to the PDF (don’t ask - it’s complicated!).

The PDF is already attached to the Sales Invoice form.

I need a no-code or very, very low-code solution!

Any advice?

Mike

1 Like

Enable this option in Notifications

Thanks for the suggestion Kenneth. That option is already enabled. The notification has the sales invoice attached correctly. I want to automatically attach a pdf that is already attached to the sales invoice form. Like this:Untitled%202 Untitled 2

Can you help?

Mike

This is not a configuration, but should be possible with some scripting.

I guess so.

This attach print does not work properly.
Can you please help out in resolving the same?

Below is the error message appears while sending the email -

Queue / Worker Job Created
home-frappe-frappe-bench:short
<function send_workflow_action_email at 0x7fcf9a707430>
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/serve.py”, line 17, in get_response
response = renderer_instance.render()
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py”, line 61, in render
html = self.get_html()
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/utils.py”, line 445, in cache_html_decorator
html = func(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py”, line 78, in get_html
html = self.render_template()
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py”, line 212, in render_template
html = frappe.render_template(self.source, self.context, safe_render=safe_render)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja.py”, line 80, in render_template
return get_jenv().from_string(template).render(context)
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/jinja2/environment.py”, line 1291, in render
self.environment.handle_exception()
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/jinja2/environment.py”, line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File “”, line 8, in top-level template code
File “/home/frappe/frappe-bench/env/lib/python3.9/site-packages/jinja2/sandbox.py”, line 393, in call
return __context.call(__obj, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja_globals.py”, line 84, in include_style
path = bundled_asset(path)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja_globals.py”, line 96, in bundled_asset
path = bundled_assets.get(path) or path
AttributeError: ‘NoneType’ object has no attribute ‘get’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/rq/worker.py", line 1013, in perform_job
    rv = job.perform()
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/rq/job.py", line 709, in perform
    self._result = self._execute()
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/rq/job.py", line 732, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 117, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py", line 293, in send_workflow_action_email
    common_args = get_common_email_args(doc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py", line 391, in get_common_email_args
    'attachments': [frappe.attach_print(doctype, docname, file_name=docname, doc=doc)],
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1608, in attach_print
    content = get_print(doctype, name, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1571, in get_print
    html = get_response_content("printview")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/serve.py", line 28, in get_response_content
    response = get_response(path, http_status_code)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/serve.py", line 23, in get_response
    response = ErrorPage(exception=e).render()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py", line 61, in render
    html = self.get_html()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/utils.py", line 445, in cache_html_decorator
    html = func(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py", line 78, in get_html
    html = self.render_template()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/page_renderers/template_page.py", line 212, in render_template
    html = frappe.render_template(self.source, self.context, safe_render=safe_render)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja.py", line 80, in render_template
    return get_jenv().from_string(template).render(context)
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/home/frappe/frappe-bench/apps/frappe/frappe/templates/web.html", line 1, in top-level template code
    {% extends base_template_path %}
  File "/home/frappe/frappe-bench/apps/frappe/frappe/templates/base.html", line 25, in top-level template code
    {%- block head -%}
  File "/home/frappe/frappe-bench/apps/frappe/frappe/templates/base.html", line 33, in block 'head'
    {{ include_style('website.bundle.css') }}
  File "/home/frappe/frappe-bench/env/lib/python3.9/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja_globals.py", line 84, in include_style
    path = bundled_asset(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/jinja_globals.py", line 96, in bundled_asset
    path = bundled_assets.get(path) or path
AttributeError: 'NoneType' object has no attribute 'get'

Hi, is it possible using JINJA template to attach pdf?

Thanks

This script adds document attachments to the notification