Hello, I have an old script to use for sending email via quotation form when I click on button. It’s possible to simplified this one to only have it on server and client script ?
Client script :
frappe.ui.form.on('Quotation', {
refresh: function(frm){
frm.add_custom_button(__("Send Email"), function() {
if (frm.doc.contact_email){
frappe.call({
method: "mm_app.script.send_email",
args: {
doctype: frm.doc.doctype,
docname: frm.doc.name
}
})
}
else{
frappe.msgprint("There is no email found for Customer")
}
})
}
})
Your code is already made simple and correct, so no need to change anything in the code. However, if you need to add something to this code, you can try using your own approach. You can’t develop something using only the client side or the server side separately. But if you want to make it so that when a quotation is submitted, an email is automatically sent, you can achieve this using only server-side scripting. Alternatively, you can also use the Notification feature in the system.
If you prefer to handle things only on the server side, utilize document events and apply the on_submit method to the document type. You can implement code scenarios such as triggering an email when a quotation is submitted. This is the only method to manage it.
If you want a similar scenario without any custom logic, you can use the notification document type.
However, you cannot manage both scripts using a single approach.
@NCP Thanks for you’r reply. What I want to do, it’s to have a button “Send email” in quotation form, and when we click on it, it’s send an email template (allready create) with the PDF attached.