Name being autogenerated

The name field is being auto generated How to set the name to Employee Name and also want to display status of the Joining Document. I am unable to do so.

Other Problem i am Facing is I want to add a button to Employee Doctype.
I used the add button function but no result.!
I want to add a function to it that whenever it is clicked a new Joining Document Will Be opened for the Employee
The Function of Joining Document is that it provides information regarding employees have been provided the fundamental resources from the company i ll paste my code too which i have done in Employee.js Document Please Look To it,

refresh: function(frm) {
var me = this;
erpnext.toggle_naming_series();

        if (frm.doc.__onload && frm.doc.__onload.joining_document) {
            frm.add_custom_button(__("Joining Document"), function() {

                frappe.set_route("Form", "Joining Document", frm.doc.__onload.joining_document);
        },
        __("View"));

    }
        else {
            frm.add_custom_button(__("Joining Document"), function() {

                frappe.route_options = {
                    "joining_document_": frm.doc.name,
                };
                    frappe.new_doc("Joining Document");

                }, __("Make"));
                cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
        }
},

Set Auto Name in respective doctype for Name and check in List View to Status to show it on list of Joining Documant.

Refer Link-
https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/custom-doctype

3 Likes

In Joining Document there is no field as Name Still it shows as this
and can u please provide steps to set it to auto name?

@daizy, Search your doctype in doctype list. In Naming Option Auto Name field is there, set naming series or fildname in that field.

1 Like

There’s no field as Auto Name.
It was There at the time of creation of the Doctype but not now.


And my problem is i dont want to name the Doctype.
The name field Displayed in the above Image is my Problem i have also made a selection in the image which is being autogenerated to a random text.

And also please help me for my other PRoblem in Employee Module.
i.e. How to add a button in the Employee Module.
i have pasted my code earlier please see through it and let me know about the problem.

@daizy
you are checking in Customize form. Please Open your Doctype from Setup > Doctype.
There is field Auto name. set with any field from your Doctype.
See below screenshot -

Here My Doctype is Post Code, as you see there is field post_code. So, I used it as my auto name > field:post_code.
Check at the bottom of the screenshot.

1 Like

How can I put a validation for the same so that No employee can have two or more than two Joining Document
Please Look on my 2nd Problem too Posted above with this.!

@daizy

There is one option unique. You can add this to employee field. Open your doctype and check unique. See below screen shot.

or you can add the custom script for that.

Sir please look into my other problem too

write a custom script for that sees following script:

frappe.ui.form.on('Employee', {
	refresh: function(frm) {
		cur_frm.add_custom_button(__('Joining Document'), function() {
			frappe.new_doc("Joining Document");
		}) 
	}
});

here I considered Joining Document is your Doctype. Replace with proper name and try.
for more details about custom script go through following link.
custom script examples

I have already Created a Joining Document for an Employee but the “make” button isnt changing to “view” Button i.e. the page isnt executing the “if” condition it is directly going to else condition. What I have tried is Similar to the Job Applicant Module but in former case cant change the button to view
Please help regarding the following code:

if (!cur_frm.doc.__islocal) {
if (cur_frm.doc.__onload && cur_frm.doc.onload.joining_document) {
cur_frm.add_custom_button(
(“Joining Document”), function() {

                frappe.set_route("Form", "Joining Document", frm.doc.__onload.joining_document);
        },
        __("View"));
        }
        else {
            cur_frm.add_custom_button(__("Joining Document"), function() {
                frappe.route_options = {
                    "joining_document": cur_frm.doc.name,
                    "employee": cur_frm.doc.Employee,
                    "employee_name": cur_frm.doc.employee_name,
                    //"designation": cur_frm.doc.job_opening,
                };
                    frappe.new_doc("Joining Document");

                }, __("Make"));
                cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
        }
    }
    },

@daizy

Please check following script and how it working. It helps you.