ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Add Sender email to description field when issue is created


#1

Hi there.
Im trying to figure out how to go about saving the sender email automatically when a Issue is created. The sender email is saved in the timeline below, but how do you save it to a field in the form itself?


This needs to be saved to a field in issue as well

Any advice?


#2

I don’t think this is possible out of the box. You’d have to edit the function make_issue_from_communication In the file frappe/email/inbox.py


#3

Hi @peterg,
I have thought about it and i would probably have to insert directly into the database from there and it will reflect in the field, but how would i insert this?

Also how is this function called or where?


#5

It’s called from erpnext/public/js/communication.js, which overrides/extends the default frappe communication.js

You wouldn’t need to call the database directly, just add an arg to the js call and then use that argument in the frappe.get_doc call. Honestly, I’m not sure why code related to the issue doctype is being included in the frappe codebase in the first place, but I’m still trying to wrap my head around the Inbox design.


#6

Do you perhaps have a clue why i receive more than one issue at a time?
I have 2 email accounts. Could that be the reason?


#7

When you click “make > issue”, you’re getting two issues created? With modified code or unmodified code?


#8

Firstly i got 2 email accounts.
Secondly i got 2 issue doctypes, The second one has been customized because this issue has a certain purpose. Each email appends to its own Issue doctype.

And lastly i dont make a issue i email the account and issue is created automatically


#9


This didnt work. I feel it should have.
my code :
“description_field”: doc.text_content,
“description_field2”: doc.content,


#10

Ah, if you’re doing it by the email account’s attachment to doctype method, modifying the js API call won’t help. You’ll have to look at the append to doctype code.


#11

Where can i find this file or method? At the moment i appended the other doctype in the hooks.py


#12

On quick glance, it looks like the create_new_parent method in email_account.py


#13

Hi @peterg
Sorry for bothering again.
I still havent solved this issue as of yet.

In make_issue_from_communication i added :
“Field1”: doc.text_content,
“Field2”; doc.content,

Shouldnt this add to my Issue doctype the content of the email into those 2 fields?


#14

Raees please don’t @ folks to solicit help thanks.

“Shouldnt this add to my Issue doctype the content of the email into those 2 fields?”

One sure way to find out would be for you to to search, run and experiment with the code.

These tests would seem to be an excellent place to start

(env) frappe@ubuntu:~/frappe-bench$ find . -name ‘*.py’ | xargs grep test_*email
grep: ./apps/erpnext/erpnext/docs/user/manual/en/non_profit/Grant: No such file or directory
grep: Application/init.py: No such file or directory
./apps/erpnext/erpnext/hr/doctype/daily_work_summary/test_daily_work_summary.py: def test_email_trigger(self):
./apps/erpnext/erpnext/hr/doctype/daily_work_summary/test_daily_work_summary.py: def test_email_trigger_failed(self):
./apps/erpnext/erpnext/hr/doctype/salary_slip/test_salary_slip.py: def test_email_salary_slip(self):
./apps/frappe/frappe/email/doctype/newsletter/newsletter.py: self.recipients = frappe.utils.split_emails(self.test_email_id)
./apps/frappe/frappe/email/doctype/newsletter/newsletter.py: frappe.msgprint(_(“Scheduled to send to {0}”).format(self.test_email_id))
./apps/frappe/frappe/email/test_email_body.py: def test_email_content(self):
./apps/frappe/frappe/email/test_email_body.py: def test_email_header(self):
./apps/frappe/frappe/core/doctype/communication/test_communication.py: def test_email(self):
./apps/frappe/frappe/test_runner.py: set_test_email_config()
./apps/frappe/frappe/test_runner.py:def set_test_email_config():
./apps/frappe/frappe/tests/test_email.py: def test_email_queue(self, send_after=None):
./apps/frappe/frappe/tests/test_email.py: self.test_email_queue(send_after = 1)
./apps/frappe/frappe/tests/test_email.py: self.test_email_queue()
./apps/frappe/frappe/tests/test_email.py: self.test_email_queue()
./apps/frappe/frappe/tests/test_email.py: def test_email_queue_limit(self):