Customize form - how to show drop down for "account" but select only "account_number"? How to limit select to account_number prefixed with GLC-?

there are variables:

  • Account (doctype?)
  • account_name
  • account_number

so it is like:

account_number: GLC-0001
account_name: salaries and wages
Account: GLC-0001 salaries and wages

account_number: GLC-0002
account_name: travel
Account: GLC-0002 travel

I think “Account” combines “account_number + account name”

In my Purchase Order form, I want user to be able to make selection based on the full account_name + account number, but I only want to store the associated account_number from that selection.

so if it was html it would be equivelent of like…
<option value="GLC-0002">GLC-0002 Travel</option>

if that makes sense.

Also, if possible, I also would like to limit the selections from “Account” or account_number to those starting with GLC-

Any help appreciated. If I figure it out, I’ll post follow up.

I have been trying… I expect this to be the answer, but it still stores in {{ gl_code }} the full name of “Account” selected instead of just the account_number

In this row #130, the Fetch From (account.account_number) is useless
Link will always get the “name” field of the linked Table Account.
If you want to get the account.account_number, insert another row in the DocType:
Label: Account Number
Type: Data
Read-only checkbox: checked
Fetch From: account.account_number

For me this does not work… I add {{doc.gl_code_number}} to my print format document and it just shows “none” for this field. I removed the “fetch from” on previous row #130 as you suggest it will do nothing, but I still use row #130 to select account for this value of #131. Doesn’t work…

You do not delete row #130.
The account link is the linking field. (name)
The account code is just fetched, if you like, to provide additional info.
Honestly, for me, this is one of the achilles hill of ERPNext - long account name plus side effect.

Ok…let me redo from scratch to show you it doesn’t work… maybe I am doing something wrong?

I create row 130 and 131 in Purchase Order “Customize Form” screen…

{{doc.account_number}} variable called in my Print Format:


I create a draft PO, and at bottom I select an “account_name” and submit to create my draft PO…

I then print my draft PO using “Print Format” template defined earlier and here is my {{doc.account_number}} number as "GL Code: " in the rendered PDF…


Did you check Read Only for gl_code_number?

Also, try saving the record again. Those previously saved will not have the glcode_number updated. When you save, it is also important to note that Frappe will only save the record if changes where made. (This is probably why the glcode_number is blank when you printed it.)

Got it working… fetch from needs to be account_name.account_number (yes it was read only as well)


@Joseph_Marie_Alba1 thanks for all the help. Part of my problem was when I first created the topic of this question I wasn’t sure how to ask it (new to ERPNext).

When I made new thread with clear question:

@Smit_Vora was able to provide answer.

1 Like