Error in set_value

Hi,
using the following script i want to set value in lead .
frappe.call({
“method”: “frappe.client.set_value”,
“args”: {
“doctype”: “Lead”,
“fieldname”: “name”,
“fieldname”: “lead_owner”,
“value”: email
},
async: false
});
but i am getting error message :
Capture4

Probably your issues lies somewhere here.

Also,

Is email a local JS variable or a string ?

Hi, @root13F
var email = $("[data-fieldname=‘email’]").val();
“value”:email (it is a local variable.)

Thank You

i am not sure but try this:

frappe.call({
"method": "frappe.client.set_value",
"args": {
"doctype": "Lead",
"name": cur_frm.doc.name,
"fieldname": "lead_owner",
"value":cur_frm.doc.email
},
async: false
});

Hi @Maheshwari_Bhavesh
what i am exactly doing…

  1. create a button in User Dashboard.
  2. on that button opening a dialog box.
  3. from this dialog box user can select email_id & this email_id should be set in lead_owner field in lead doctype.

Capture5Capture6

Thank You

@Maheshwari_Bhavesh
i am trying your script but still giving error.
TypeError: set_value() takes at least 3 arguments (3 given)

Thank You

necessary to pass lead name in arguments but in user setting lead number not available. you should add one more field in pop up for select lead number and pass that number in argument

let’s see if user can assign bulk lead then in this case my scenario will be failure.

I found the Solution.
Thank You so much for your help

share solution

@Maheshwari_Bhavesh

var actual_owner=cur_frm.doc.email;
frappe.call({
		method: 'frappe.desk.doctype.bulk_update.bulk_update.update',
		args: {
			doctype: 'Lead',
			field: 'lead_owner',
		    value: email,
			condition: "lead_owner='"+actual_owner+"'",
            limit: 100
		},
        callback:function(res){
               dialog.hide();
        }
});

mark this as solution instead.