Doctype Naming Rule

Hi everyone !
I want to set the doctype name based on checkbox value.
For example if checkbox is checked, the name of doctype must be the same as “field X”.
Or if checkbox is not checked the name of doctype must be the same as another field like “field Y”.
Can you have an idea about this?

use naming series for naming and script can be used like below

frappe.ui.form.on("Sales Invoice", {
    sales_type: = function(doc, cdt, cdn) {
        // this function is called when the value of company is changed.
        if (cur_frm.doc.sales_type === 'Domestic') {
            cur_frm.set_value("naming_series", ".abbr..year./.####");
        } else if (cur_frm.doc.sales_type === 'Export') {
            cur_frm.set_value("naming_series", "EXP/.year./.###");
            cur_frm.set_value("company", "ELTECH ENGINEERS PRIVATE LIMITED");
        } else if (cur_frm.doc.sales_type === 'Export EOPL') {
            cur_frm.set_value("naming_series", "EXPEOPL/.year./.##");
            cur_frm.set_value("company", "ELTECH OZONE PVT LTD");
1 Like

Better use document naming rule
And add your condition

Thank your for your answer, how I can do this?

Thank you for your answer I will try it

This is a very nice feature, can I write another fieldname in the ‘Prefix’ field here?
For example: supplier_name field from Purchase Order doctype

Yes Your can write check naming series rule

Yes, I tried it, and it’s working as I wanted. Thank you so much.