Hi All,
I need uncheck checkbox while creating opportunity from lead to deal ,Create Prospect in quick entry in lead i need solution for this
Thanks in Advance
Hi All,
I need uncheck checkbox while creating opportunity from lead to deal ,Create Prospect in quick entry in lead i need solution for this
That for, please apply the client script for the lead doctype.
frappe.ui.form.on("Lead", {
make_opportunity: async function (frm) {
let existing_prospect = (
await frappe.db.get_value(
"Prospect Lead",
{
lead: frm.doc.name,
},
"name",
null,
"Prospect"
)
).message.name;
if (!existing_prospect) {
var fields = [
{
label: "Create Prospect",
fieldname: "create_prospect",
fieldtype: "Check",
default: 0,
},
{
label: "Prospect Name",
fieldname: "prospect_name",
fieldtype: "Data",
default: frm.doc.company_name,
depends_on: "create_prospect",
},
];
}
let existing_contact = (
await frappe.db.get_value(
"Contact",
{
first_name: frm.doc.first_name || frm.doc.lead_name,
last_name: frm.doc.last_name,
},
"name"
)
).message.name;
if (!existing_contact) {
fields.push({
label: "Create Contact",
fieldname: "create_contact",
fieldtype: "Check",
default: "1",
});
}
if (fields) {
var d = new frappe.ui.Dialog({
title: __("Create Opportunity"),
fields: fields,
primary_action: function () {
var data = d.get_values();
frappe.call({
method: "create_prospect_and_contact",
doc: frm.doc,
args: {
data: data,
},
freeze: true,
callback: function (r) {
if (!r.exc) {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
frm: frm,
});
}
d.hide();
},
});
},
primary_action_label: __("Create"),
});
d.show();
} else {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
frm: frm,
});
}
},
});
it is not working ;opportunity doctype i renamed as “Deal” and Prospect doctype renamed as “Accounts”
I provided the code for what you wanted. Now remove that button for what you want, and add another new button, and perform the action on it. Renaming the button won’t help.
i just need directly create lead to Deal(opportunity) no need of Prospect the below screenshot that quick entry of Create Accounts(Prospect) not need
Code already provided, did you check? I think you haven’t seen it. Only you have to select the create option and it will redirect to the opportunity doctype.
Hmm
Will check it from my end.
Again, please apply the below code:
frappe.ui.form.on("Lead", {
refresh: function(frm) {
setTimeout(() => {
frm.remove_custom_button('Opportunity', 'Create');
}, 10);
if (!frm.is_new() && frm.doc.__onload && !frm.doc.__onload.is_customer) {
setTimeout(() => {
frm.add_custom_button(
__("Opportunity"),
function () {
frm.trigger("custom_make_opportunity");
},
__("Create")
);
}, 50);
}
},
custom_make_opportunity: async function (frm) {
let existing_prospect = (
await frappe.db.get_value(
"Prospect Lead",
{
lead: frm.doc.name,
},
"name",
null,
"Prospect"
)
).message.name;
if (!existing_prospect) {
var fields = [
{
label: "Create Prospect",
fieldname: "create_prospect",
fieldtype: "Check",
default: 0,
},
{
label: "Prospect Name",
fieldname: "prospect_name",
fieldtype: "Data",
default: frm.doc.company_name,
depends_on: "create_prospect",
},
];
}
let existing_contact = (
await frappe.db.get_value(
"Contact",
{
first_name: frm.doc.first_name || frm.doc.lead_name,
last_name: frm.doc.last_name,
},
"name"
)
).message.name;
if (!existing_contact) {
fields.push({
label: "Create Contact",
fieldname: "create_contact",
fieldtype: "Check",
default: "1",
});
}
if (fields) {
var d = new frappe.ui.Dialog({
title: __("Create Opportunity"),
fields: fields,
primary_action: function () {
var data = d.get_values();
frappe.call({
method: "create_prospect_and_contact",
doc: frm.doc,
args: {
data: data,
},
freeze: true,
callback: function (r) {
if (!r.exc) {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
frm: frm,
});
}
d.hide();
},
});
},
primary_action_label: __("Create"),
});
d.show();
} else {
frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
frm: frm,
});
}
},
});
Thank you so much it is working