[SOLVED]: Customize Form: without coding, using the GUI

Hi all,

I want the Supplier’s TIN no to be read and displayed when the customer selects the SUPPLIER in the Purchase Order.
I am not a programmer, thus would appreciate if you guys can guide me to make this happen without me having to write code.

Thanks a lot,
Dhanush

Hi u should hide field in DocType.

Go to Setup → Customize Form …select the doc type then check hidden field in TIN field.

Hi,

you can use Depends On in the permission section, add eval: doc.supplier in the depends on.
The Supplier TIN will only show if the supplier is selected otherwise the field will be hidden.

Thanks, Makarand

2 Likes

Hi Makarand,

thank you for your response. I have added the piece of code you provided (pic attached).

But the issue is the TIN no is not being extracted, only the TIN selection box is being shown (pic-2 attached). I want the fetched TIN to be displayed in place of the supplier’s name.
What am I doing wrong here.

Also, I’m still in the early stages of using ERPNext. Please correct me in case the issue is silly or irrelevant.

thanks,
Dhanush

Hi JoEz,

it is not hidden. I am unable to fetch the “TIN” number from Supplier records and display when the Supplier is selected.

thanks,
Dhanush

@Dhanush yeah i got it …marakand solution is the one u need …did u reload the page?

@JoEz Yes JoEz, but it isn’t working. Maybe I need to change the Custom Field type into something else, but i’m not sure which one.

This is what i’ve got after applying Marakand’s solution.

I need to again select the Supplier from the list. It has to be automatically displayed.

thanks,
Dhanush

@Dhanush what’s the name of supplier field?

it is “TIN”.

So u have 2 Supplier fields? Supplier and TIN?

Yes, and when the Supplier is selected the respective TIN has to be fetched and displayed next to it.
Is it possible?

Cant understand what u need to have …what’s TIN? The TAX ID? or what?

Yes JoEz, it is Tax ID. A unique number for each supplier.

Ok …so u have it it in Supplier Doc …right?

You need to add a custom script in Purchase Order, and if u have TIN in Supplier DocType use

frappe.ui.form.on("Purchase Order", "onload", function (frm) {
    frm.add_fetch("Supplier", "tin-from-supplier", "tin-to-purchase-order");
});

and change:

tin-from-supplier with the TIN field name in Supplier DocType

tin-to-purchase-order with the TIN field name in Purchase Order DocType, make this as Data and Read Only

@JoEz

thanks JoEz. I did the following.

  1. Added “custom Script” and changed the names as in the supplier and purchase order doctypes.

Ref-1:

Ref-2:

But the TIN field isn’t visible when the Supplier is selected. (Pic attached)

Have I missed out linking anywhere ?

PS: thank you so much for your patience. Really appreciate your help in this regard.

@Dhanush, you have to add script in Purchase Order instead of Supplier

@JoEz I did that, still not showing :neutral_face:

@Dhanush it’s kind of strange

remove eval:doc.supplier

…did u reload after changes? see pic …

What’s the value of TIN in Supplier?

I removed the “eval:” statement and I reload it every time I make any changes.
Here are a few things I noticed:

  1. If I name that field as “test” and not link it to the supplier field via the custom script the test box is visible. But when I rename it as “TIN” it vanishes.
  2. can you confirm if the format of “add_fetch” which you’ve mentioned above?
    It isn’t working and also I saw a few others using single quotes ( ’ ) for the parameters within.