Select Account via Custom Button

Hi all,

I added a custom button to Expense Claim. My aim is to create a Journal Entry very similar to the one created using the standard make_bank_entry method on click of the button. There is however one significant difference:

With the standard method, the ‘Creditors’ account is automatically selected (with Employee as Party). I however want another account (which I can specify using a custom field in the Expense Claim) to be automatically selected instead

How can I achieve this? Preferably without any server-side scripting. Any assistance or samples would be greatly appreciated

Thanks

I’m using the code below but I want to set a different account to be debited (instead of the Creditors account which gets populated by default)

frappe.ui.form.on("Expense Claim", {
refresh: function(frm,dt,dn) {	
//cur_frm.cscript.custom_validate(frm.doc);

	if(frm.doc.docstatus == 0) {
	//	if(doc.status != 'Closed') {
			cur_frm.add_custom_button(__('Custom Payment Button'), cur_frm.cscript.make_bank_entry, __("Make"));
	//	}
		cur_frm.page.set_inner_btn_group_as_primary(__("Make"));	
	}
    },
})

I prefer to avoid server-side scripting because this is for a cloud-hosted account. Please let me know how I can achieve this

Thanks

Hi @wale

Check below link
https://github.com/frappe/erpnext/blob/develop/erpnext/hr/doctype/expense_claim/expense_claim.js#L15-L16

Here r.message data gets from the server, you can prepare this data in the JS side but will require some more efforts

Hi @rohit_w

Thanks ever so much. I’ll explore this further

Kind regards,

Hi @rohit_w

Trust you’re doing well. I’ve tried but haven’t found a way to prepare data for r.message on the JS side since it generally works with the defined method (which is in py). Could you give me some more pointers in this regard?

Also, is there any way for ERPNext cloud users to create a custom method (on the py side)?

Please help

Thanks

Hi @wale

Can you share latest json file I’ll try from my end to add the records