I have read some posts regarding Link formatters. Most of the posts are talking about adding more info to the link value.
While my case is to remove the unnecessary info.
This is my case:
- I have doctype A with these 2 fields:
field1
,field2
. - Because of the nature of the data, both field will have duplicated data.
- So I use
field1 - field2
for the Auto Name.
Then in other doctype B: - I have a link type field pointing to the above doctype.
- Because of the auto naming, the dropdown link shows
field1 - field2
- What I want is only to show
field1
on this link dropdown.
I think the frappe.form.link_formatters
can be used for this. But I’m struggling to make it work. No error, no message in the console.
Here is my code:
frappe.ui.form.on( 'Doctype B', {
before_load: function ( frm ) {
frappe.form.link_formatters[ 'Doctype A' ] = function ( value ) {
return value.split(" - ")
}
}
}
Can anyone help please?
Thank you.