Thanks Nabin,
I corrected all the syntax errors, but with no result.
I have two questions regarding this.
can i add another script on the same file. i.e there is a already a script on the Sales Invoice_Client, and i need the effect to be on Sales Invoice?
2 is the script function (cur_frm.cscript.custom_validate = function(doc)) proper function for achieving the desired result.
yes, you can add multiple function in sales custom script record.
If you write the logic in custom_validate, income_account will be set on saving of document. If you want to set income_account on_change of item or sales_type, you have to call the function on trigger of those field. For on_change event syntax, check https://frappe.io/docs/guide/form-client-scripting.
In above code, doc.income_account is wrong, it should be d.income_account.
Can you share your final code?
I had already formatted this code also as the first one , i don’t know how it happens like that. Any way i posted the same code on GitHub gist with proper formatting, is that ok?.