Skip to content

Instantly share code, notes, and snippets.

@sbkolate
Created February 9, 2016 15:17
Show Gist options
  • Save sbkolate/bbab82f16722b19cdc2b to your computer and use it in GitHub Desktop.
Save sbkolate/bbab82f16722b19cdc2b to your computer and use it in GitHub Desktop.
cur_frm.add_fetch('contact1','email_id','contact_email_i');
cur_frm.add_fetch('contact2','email_id','contact_email_ii');
cur_frm.add_fetch('contact3','email_id','contact_email_iii');
frappe.views.CommunicationComposer = frappe.views.CommunicationComposer.extend({
make_fun: function(){
var me = this;
var content_field = me.dialog.fields_dict.content;
var subject_field = me.dialog.fields_dict.subject;
var recipients_field = me.dialog.fields_dict.recipients;
var rec = me.dialog.fields_dict.recipients.get_value();
var custom_rec="";
if(cur_frm.doc.contact_email_i){custom_rec = custom_rec + ","+cur_frm.doc.contact_email_i}
if(cur_frm.doc.contact_email_ii){custom_rec = custom_rec + ","+cur_frm.doc.contact_email_ii}
if(cur_frm.doc.contact_email_iii){custom_rec = custom_rec+ ","+cur_frm.doc.contact_email_iii}
recipients_field.set_input(rec + custom_rec +",sales@nandan.co.in")
recipients_field.set_input(rec + custom_rec +",sales@nandan.co.in")
},
make: function(){
this._super();
this.make_fun();
}
});
frappe.ui.form.on("Lead", "refresh", function(frm, doctype, name) {
cur_frm.set_query("contact1", function() {
return {
"filters": {
"customer_name": frm.doc.customer
}
};
});
cur_frm.set_query("contact2", function() {
return {
"filters": {
"customer_name": frm.doc.customer
}
};
});
cur_frm.set_query("contact3", function() {
return {
"filters": {
"customer_name": frm.doc.customer
}
};
});
});
frappe.ui.form.on("Lead", "refresh", function(frm, doctype, name) {
cur_frm.add_custom_button(__('Add Interaction'), function() {
var d = frappe.prompt([
{label:__("Type of Interaction"), fieldtype:"Select",'default': "Call",
options: ["Call","Mail","Face to Face","SMS","Skype"],
fieldname:"type_of_interaction"},
{label:__("Result"), fieldtype:"Select", options:
["Status Quo","Warmer","Colder","Closed Lost","Closed Won"], fieldname:"result"},
{'fieldname': 'responsible', 'fieldtype': 'Link', options:"User", 'default': user, 'label': 'Responsible', 'reqd': 0},
{fieldtype: "Column Break"},
{'fieldname': 'person_interacted_with', 'fieldtype': 'Data', 'label': 'Person Interacted with', 'reqd': 0},
{'fieldname': 'next_date', 'fieldtype': 'Date',
'label': 'Next Action Date', 'default': frappe.datetime.add_days(frappe.datetime.nowdate(),7), 'reqd': 0},
{'fieldname': 'next_action_by', 'fieldtype': 'Link', options:"User", 'default': user,'label': 'Next Action By', 'reqd': 0},
{fieldtype: "Section Break"},
{'fieldname': 'comment', 'fieldtype': 'Text', 'label': 'Next Action Task', 'reqd': 1}
],
function(values){
var c = d.get_values()
var cmnt = "<br> Person Interacted_With: "+ c.person_interacted_with
+"<br>Type of Interaction: "+ c.type_of_interaction
+"<br>Result: "+ c.result
+"<br>Next Action Date: " +c.next_date
+"<br>Next Action By: "+ c.next_action_by
+ "<br>Next Action Task: "+c.comment
+ "<br>Responsible: "+c.responsible
var me = frm.doc
// start interaction master
frappe.call({
method: "ngse.custom_method.add_interaction",
args: {
doc:{
doctype: "Interaction Master",
reference_doctype: frm.doc.doctype,
reference_name: frm.doc.name,
result: c.result,
person_interacted_with: c.person_interacted_with,
// responce_reson: c.responce_reson,
// next_date: c.next_date,
type_of_interaction: c.type_of_interaction,
// result: c.result,
next_action_by: c.next_action_by,
next_action_task: c.comment,
responsible: c.responsible
}
},
callback: function(r) {
msgprint("Interaction master record created");
}
});
//end interaction master
return frappe.call({
method: "frappe.desk.form.utils.add_comment",
args: {
doc:{
doctype: "Comment",
comment_type: "Comment",
comment_doctype: frm.doc.doctype,
comment_docname: frm.doc.name,
comment: cmnt,
responce_reson: c.responce_reson,
next_date: c.next_date,
type_of_interaction: c.type_of_interaction,
result: c.result,
next_action_by: c.next_action_by,
comment_by: user
}
},
callback: function(r) {
msgprint("Interaction Submited Successfully");
if (cur_frm) {
if (cur_frm.docname && (frappe.last_edited_communication[cur_frm.doctype] || {})[cur_frm.docname]) {
delete frappe.last_edited_communication[cur_frm.doctype][cur_frm.docname];
}
// clear input
cur_frm.comments.input.val("");
cur_frm.reload_doc();
}
}
});
},
'Add Interaction',
'Submit'
)
}, "icon-exclamation", "btn-default");
frm.comments.refresh();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment