Populate link with queried Values

Hello,
My aim is to assign each ‘Trader’ (a Role) to a ‘Distributor’ (it’s also a Role). for this
I have made a SETUP doctype. It has Child Table. The child table has two link fields, both references the ‘UserRole’ table.

So, I want to populate all ‘Trader’ users in one link and all ‘Distributors’ in other link in the child table’s link fields.
How to custom script for this?

1 Like

What have you tried so far? If you are stuck we can help. If you need someone to write a script, hire someone.

@rmehta
My script is,

frappe.ui.form.on('KD Assign', {
	refresh: function(frm) {

	}
});
cur_frm.set_query("trader_link", "trader_to_kd", function(doc, cdt, cdn) {		
	return{
		filters: [
				['UserRole', 'parent', '=', "Trader"]
		]		
	}
}); 

Here,
“trader_to_kd” is the child doctype,
“trader_link” is the link field in child doctype
“KD Assign” is the parent DocType.

Could you help me please.

So where are you stuck?