Create automatically project when Opportunity create Job Awarded in Sales Stage

dear friends, in opportunity while applying “Job Awarded” as data in Sales stage i automatically need to create project list based on given opportunity data

Hi @sathya_raj,

That for, please apply the client script for Opportunity.

Code:

frappe.ui.form.on('Opportunity', {
    after_save: function(frm) {
        create_project(frm);
    }
});

function create_project(frm) {
    var salesStage = frm.doc.sales_stage;
    if (salesStage === 'Job Awarded') {
        frappe.call({
            method: 'frappe.client.insert',
            args: {
                doc: {
                    doctype: 'Project',
                    project_name: frm.doc.name
                    // Add other fields from the Opportunity that you want to copy to the Project
                }
            },
            callback: function(response) {
                if (response.message) {
                    frappe.msgprint({
                        title: __('Success'),
                        indicator: 'green',
                        message: __('Project created successfully: '+response.message.name)
                    });
                }
            }
        });
    }
}

When you save the Opportunity the Project will create.

Output:

Thank You!

2 Likes

thank you so much NCP

hi Friends,
In Opportunity when sales stage is Job Awarded saved it should create notification after 3days

Hi @sathya_raj,

Please go to the notification and set it up according to.

Please check it.

Thank You!

1 Like