Setting Default Values When Creating a New Record via Link Field

Hi everyone,

I have a designation field in one of my Doctypes, which is a Link field pointing to the Designation Doctype.

When I type in the designation field and the value doesn’t exist, the system shows a button to create a new Designation. When I click on this button, it redirects me to the Designation Doctype to create a new record with the entered value pre-filled.

Now, I want to set some default values for the new Designation record when it is created in this way. Specifically:

  • is_contractual should be set to 1
  • employment_type should be set to 'Contract'
    Screenshot from 2025-01-14 00-14-14

How can I achieve this behavior?

Any help or guidance on how to implement this using Frappe’s client-side scripting would be greatly appreciated!

Thanks in advance.

1 Like

Anyone can help in this???

setup: function(frm) {
    const proposed_designation_field = frm.get_docfield('proposed_designation');
    proposed_designation_field.get_route_options_for_new_doc = () => {
        return {
            is_contractual: 1,
            employment_type: 'Contract'
        };
    };
}