Setting Default field value to other doc type field

Hello;

I need to set the Default value of the field to be the value of the default_cash_account in the Company doc type. As shown in the below pic, I place in the Default the following: Company.default_cash_account but it did not work. Please note that Company field is already existed in the document.

I need it only to be the default value, so if the user changed the value, then the user selected value will be the field value.

How I can do it?
Regards
Bilal

Hi @bghayad,
if company is a field in your DocType that contains a link to the company DocType, try using small letter “company”, which I guess is the name of the field (Company is the type); and move it to the options area. I am not sure though if this works on a link field.

An example:

Otherwise, maybe you can set it using a client-side script, something like (concept only)

frappe.ui.form.on("YourDocType", {
  onload: function(frm) {
    if (frm.doc.docstatus==0) {
      cur_frm.add_fetch('company','default_cash_account','receiving_payment_account');
    }  
  }
});

Hope this helps.

1 Like