How to read default values via custom script in ErpNext?

Hi all,
I’ve been working to learn custom scripting in ErpNext. I added a custom field in “Sales Order” doctype named “Payment Type” (link type). In order to simplify entering sales orders, I added a doctype named “Payment Type” and store some static values in it such as “Cash on delivery”,“Credit card”,… Then I added a new custom field to the “Customer” doctype to set default_payment_type of customers which will selected from combo box.

Then I added following custom script;

frappe.ui.form.on(“Sales Order”, “customer”, function(frm, cdt, cdn) {
// Triggered when customer field updated

// Get customer
var c = frappe.get_doc(cdt, cdn);

// filter “payment type” list according to the language preference in customer account
frm.fields_dict[‘payment_type’].get_query = function(doc) {
return {
filters: { “Language” : c.language }

//----------> how to set default value of the payment_type ???

I need to set default value of the “payment type” during creating of a sales order by means of reading it from the “Customer” doctype.

I need a few lines of correct code.
Thanks for your suggestions and helps

As a note that, “Billing Currency” entered in the Customer table is very similar what I need. This default value comes automatically during order entry.

Hi @Ozgur_GUNDURU ! You may use the “on_load” function in JS to set it when you “Create” New record:

frappe.ui.form.on("Sales Order", "onload", function(frm) {

   *** Code Here