Hi Showing when i try to populate datas from customer to sales order


when i try to populate datas from customer to sales order

Hi @amal_31845,

It does not work. You should apply the client script for fetching the customer details in the sales order. otherwise use the fetch from.

please check the reference.

Thank You!

Can you show me a client script to get a value from one doctype to another doctype
example :
when employee is selected in sales invoice the mobile no should populate automatically in the sales invoice

Thanks

If the mobile number is in the employee master then you can easily fetch the details in invoice using the reference which I provide.

Screenshot 2024-04-03 164437
this is the designation in employee
you can see the Zonal manager.

image
this is the zonal manager field in the Customer
While creating a customer we need to show the employees who have designation as Zonal Manager (the user will select the correct zonal manager we only need to show as a dropdown)

This is what i want

Please check the simple one.

sorry brother Mobile is not the one

Really i want to filter the employees to sales order where the employees designation is “Zonal manager”

How can i filter the employees ?

frappe.ui.form.on('Customer', {

onload: function(frm) {
        // Fetch and populate Zonal Managers when the form is loaded
        fetchAndPopulateZonalManagers(frm);
    }
});

function fetchAndPopulateZonalManagers(frm) {
    // Query Employees with designation 'Zonal Manager'
    frappe.call({
        method: 'frappe.client.get_list',
        args: {
            doctype: 'Employee',
            filters: {
                designation: 'Zonal Manager'
            },
            fields: ['name', 'employee_name']
        },
        callback: function(response) {
            if (response.message && response.message.length > 0) {
                // If Zonal Managers found, populate the field
                let zonalManagers = response.message;
                let zonalManagerOptions = [];
                zonalManagers.forEach(function(manager) {
                    zonalManagerOptions.push({
                        'label': manager.employee_name,
                        'value': manager.name
                    });
                });
                // Set options for Zonal Manager field
                frm.set_df_property('custom_zonal_managers', 'options', zonalManagerOptions);
                frm.refresh_field('custom_zonal_managers');
            } else {
                // No Zonal Managers found, show a message
                frappe.msgprint(__('No Zonal Managers found.'));
            }
        }
    });
}