I know that when I customize the “Batch” form I can add more search_fields but that’s not what I want. I want the text that is written bold here to be the batch_id and not the name. For the dropdown list and the “Link Field” itself.
Is that something that is currently achievable? In terms of adding code to my custom app?
Because I guess this is something that would have to be changed withing frappe. If so and if I would implement this and send a Pull Request with this, would that be something that will be accepted? If not, then I guess I have to find another way around this.
The only thing that is a little bit annoying with the link_formatters is that you can not make reference to fields of the selected document, only to fields present in the current document. This force me to duplicate content or make a REST call for each displayed field.
I know there is no easy solution to this problem but it would be such a great step forward
I just found that when you manipulate the “Link Field”'s query with cur_frm.fields_dict.batch_no.get_query for example and then in your server-side function do return frappe.db.sql('select batch_id from tabBatch') it’s kind of working.
Because the first value after the “select” is always the one in the list written bold.
The only thing that’s not working is that when you do it like this and click the item in the list it isn’t set. I guess it’s the same like this:
I’m trying to understand this and write a function that uses get_query and link_formatters to achieve what I described in my first post. And to have it easily reusable for other fields.
I appreciate any additional information that can help me with this.
Continuing from this post because it is relevant and I just realized it was posted a year ago.
So I just tried getting this to work by altering the validation of the “Link Field” so it accepts the first item in df.search_fields but then the link from the “Link Field” points to a non-existing doc.
So I’m proposing now that the whole functioning of a “Link Field” needs to be rewritten to have better control as a developer over what exactly is displayed in the dropdown list and in the selected input field.
Thanks but that’s not what I mean. In the dropdown there’s the “name” in black and bold on top and beneath are the additional “Search Fields” as you suggest. But I want to change the text that’s in black and bold to be the “batch_id” field like in my example.
I just commented out frappe.require('assets/title_links/templates/list_item_main.html'); and now the js error is gone. Everything seems to work, at least for my custom fields where there’s just the default link dropdown in use.
For the ERPNext DocTypes like “Quotation” the dropdown list still isn’t showing the doc’s title.
But on selecting, the title is inserted into the input field. So this is working.