Send email alert to recipients on child document field

Hi ,

Is there any way to send out email alerts to recipients (email addresses) in a child table?

Any assistance would be appreciated

Thanks

Hello,
Can you elaborate? Which child table of which doctype are you referring to? In the email alert report, what do you wish to captuor
If possible, please send screenshots.
Awaiting response for above information.

Not out of the box currently (at least in v10) but as a workaround you can have a hidden field and write a custom script to copy child table’s email id in that field when saving the document. That way you will have a field with email in your doctype and now you can set an email alert for that field. Make sure in that hidden custom field you select type as Data and in option put Email

Hi @jaichavan

Thanks a lot for your response. It doesn’t have to be any specific doctype as long as it contains a child table. Let’s take for example the Project doctype which contains Project User child table. What if that child table contains a field project_user_email and I want email alerts to be sent to all those email addresses every time the Project doctype is saved?

Please let me know if you require further clarification

Thanks

Hi @palashjhabak

Thanks a lot for this suggestion. I’m however wondering how to make this work considering that the child table is likely to have several email addresses. How do we deal with that? If you can also give any sample script in this regard, it will be very helpful

Thanks again

Sure you can map it to a field in the current/parent doctype. Below in an example of a custom script that you should create

cur_frm.add_fetch(doctype_name,‘email_id’,‘email_id_alert’)

Create a custom script with above code on your Parent Doctype. What it does is, it copies data of email_id field in your child doctype to a custom field email_id_alert (You can create custom fields in your doctype by Customizing Form https://erpnext.org/docs/user/manual/en/customize-erpnext/customize-form) in your Parent doctype.

Now if you have several mail ids in your child doctype, you can use the field on which you want to send email alert to as 2nd argument in the above function call. And if you want to send it to multiple mail ids from the child table, then I am afraid you will have to create those many number if fields.

I hope its clear now, if not please feel free to ask.

PS: If someone else has a better solution, will really appreciate your guidance.