Skip to content

Instantly share code, notes, and snippets.

@sbkolate
Created January 5, 2016 12:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sbkolate/63449d59e8dc7dddc419 to your computer and use it in GitHub Desktop.
Save sbkolate/63449d59e8dc7dddc419 to your computer and use it in GitHub Desktop.
frappe.ui.form.on("Quotation", "refresh", function(frm, doctype, name) {
cur_frm.add_custom_button(__('Add Interaction'), function() {
var d = frappe.prompt([
{label:__("Type of Interaction"), fieldtype:"Select",
options: ["SMS", "Call", "Visit", "Webex"],
fieldname:"type_of_interaction"},
{label:__("Result"), fieldtype:"Select", options: ["Status Quo", "Warmer", "Colder"], fieldname:"result"},
{fieldtype: "Column Break"},
{'fieldname': 'responce_reson', 'fieldtype': 'Data', 'label': 'Responce Reson', 'reqd': 0},
{'fieldname': 'next_date', 'fieldtype': 'Date', 'label': 'Next Action Date', 'reqd': 0},
{'fieldname': 'next_action_by', 'fieldtype': 'Link', options:"User", 'label': 'Next Action By', 'reqd': 0},
{fieldtype: "Section Break"},
{'fieldname': 'comment', 'fieldtype': 'Text', 'label': 'Comment', 'reqd': 1}
],
function(values){
var c = d.get_values()
var cmnt = "Responce Reason: "+c.responce_reson + "<br>Comment: "+c.comment + "<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
var me = frm.doc
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