Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to set default email recipients #25555

Merged
merged 2 commits into from Mar 22, 2024

Conversation

barredterra
Copy link
Collaborator

@barredterra barredterra commented Mar 20, 2024

Currently, when emailing a document, users have to manually select recipients, CC and BCC (recipients sometimes get filled from the document). However, in standard processes like Sales Order -> Delivery Note -> Sales Invoice, the email addresses are often pre-defined. This is done in advance by the account manager. It should not be the responsibility of the storekeeper or accountant to figure out the correct recipient and CC addresses.

This PR enables us to set default recipients via a Client Script. Every form can programmatically supply it's own default recipients.

CommunicationComposer (the email dialog) will check if there is a client script supplying default recipients. This will allow us to do things like:

frappe.ui.form.on("Quotation", {
	get_email_recipients: function (frm, field) {
		// field can be "recipients", "cc" or "bcc"
		if (field === "bcc") {
			return [frm.doc.custom_bcc]
		}
	},
	// ...
};

Docs: https://frappeframework.com/docs/user/en/api/form#form-events, https://frappeframework.com/docs/user/en/desk/scripting/client-script#3-6-set-default-email-recipients

@barredterra barredterra requested a review from a team as a code owner March 20, 2024 00:20
@barredterra barredterra requested review from ankush and removed request for a team March 20, 2024 00:20
communication.js:206 Uncaught TypeError: Cannot read properties of undefined (reading 'events')
    at frappe.views.CommunicationComposer.get_default_recipients (communication.js:206:16)
    at frappe.views.CommunicationComposer.get_fields (communication.js:57:19)
    at frappe.views.CommunicationComposer.make (communication.js:25:17)
    at new frappe.views.CommunicationComposer (communication.js:16:8)
    at Object.primary_action (communication__list_js:34:3)
    at HTMLButtonElement.<anonymous> (list_view.js:1432:19)
    at HTMLButtonElement.dispatch (jquery.js:5135:27)
    at elemData.handle (jquery.js:4939:28)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
@ankush ankush merged commit 4c85626 into frappe:develop Mar 22, 2024
24 checks passed
@barredterra barredterra deleted the default-email-recipients branch March 22, 2024 12:43
@barredterra barredterra self-assigned this Mar 22, 2024
@barredterra barredterra added the add-docs New feature should be have an entry in documentation to increase the discoverability label Mar 22, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2024
@barredterra barredterra added backport version-14-hotfix backport to version 14 backport version-15-hotfix Backport the PR to v15 labels Apr 11, 2024
@barredterra barredterra removed the add-docs New feature should be have an entry in documentation to increase the discoverability label Apr 11, 2024
@frappe frappe unlocked this conversation Apr 11, 2024
@frappe frappe locked as resolved and limited conversation to collaborators Apr 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14 backport version-15-hotfix Backport the PR to v15
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants