Change "Add Task" button target in CRM Lead doctype

Hello! I posted this yesterday, but for some reason it didn’t get posted to the community, so I’m trying again…

Anyone? I appreciate your help!

Hi @jennlawlor

Please try this client script.

frappe.ui.form.on(‘Lead’, {

refresh: function(frm) {

    // Add button in the activity section

    frm.add_custom_button(\_\_('Create Task'), function() {

        // Open a new Task form

        frappe.prompt(\[

            {

                'fieldname': 'project',

                'fieldtype': 'Link',

                'label': 'Project',

                'options': 'Project',

                'reqd': 1

            },

            {

                'fieldname': 'subject',

                'fieldtype': 'Data',

                'label': 'Task Subject',

                'reqd': 1

            }

        \],

        function(values){

            frappe.new_doc('Task', {

                project: values.project,

                subject: values.subject,

                reference_type: 'Lead',

                reference_name: frm.doc.name

            });

        },

        \_\_('Enter Task Details'),

        \_\_('Create Task')

        );

    }, \_\_('Create')); // Adds under "Create" dropdown

}

});