I am trying to send the delivery note by email Notification to the transporter (supplier). Under notification, I see the option to send email by Role (to supplier). Will that send email to all suppliers? Or Supplier associated with that document?
I thought of creating a custom field in delivery note called supplier_email. how to link it to the supplier contact (fetch email address of supplier)?
All suppliers. If you send a notification role-wise, all users having the role will be updated. The option is to create a field and enter “Email” in option. This will allow you to select the email field in notification.
The easiest way to do this:
Create custom link field for contact doctype.
Create custom field type: data, option: Email.
For the email field, fetch the email address from contact.
If you want additionally to only select a supplier and based on that the rest of the process to be automated, you can look at custom script options.
Doctype Contact seems already has a data field for email_id. In delivery note, customer contact_email is populated automatically - so I am assuming I do not need to recreate a link field? On a side note, wondering how contact_email in delivery note automatically links to email address of customer contact.
Per your instructions (I think!) , I created a custom field for Delivery Note called transporter_email. It is of type Data with Options as Email. Under fetch I tried supplier.contact.email_id, and transporter.contact.email_id. None of them work - so will appreciate clarity on how to fetch ins Step 3? Transporter is named in Delivery Note from dropdown (line 96 of form). I have added custom field after this row (line 103 in std doctype). Does that make sense?
Big shout out to @hrwx for contributing this script. Sincere thanks on behalf of the community. Script dynamically filters doctype contacts for supplier and then for the transporter and return the primary contact default email_id field. It can be applied for other situations where you need to pull a field (in this case email_id) from one doctype (contact / supplier) to another doctype (delivery note) with dynamic filters (based upon a user selection - in this case transporter as a subset of suppliers).
Small explanation for future reference:
The first step is to create a custom field in Delivery Note called transporter_email, with options as Email. Then need to add this custom script for document type Delivery Note. This transporter_email will now be available as an option under email Notification - so delivery note can be sent to transporter upon submit.