How to auto fill-up Sales Team table under Sales Order?

Hi all,

Our sales person = sales user. I want to auto fill up the Sales Team table every time they open a new Sales Order. I understand it may need Custom Client Script? Can someone point some direction?


If sales person is based on the selected customer, then it can set in the customer master. If it is based on the current user means, need to add a custom script in sales order form frappe.session.user…

Hi @maxchock,

Please apply custom/client script.

frappe.ui.form.on('Sales Order', {
	setup: function(frm) {
	    if (frm.doc.docstatus === 0 && !frm.doc.sales_team[0]) {
	        var d = frm.add_child("sales_team");
	        if (frappe.session.user === "Administrator") {
    		    d.sales_person = "Sales Person 2";
	        else if (frappe.session.user === "") {
    		    d.sales_person = "Sales Person 1";

Please set yours according to the session user and salesperson.

Thank You!

Thanks for the example code! Very much appreciated.

I’m wondering is there a way to get like:
1- get employee ID using user ID.
2- get sales person using employee ID.

So I don’t have to update the custom script if there is a new sales person.

Thanks again~!