Link formatter to remove unnecessary value

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.

Just see this docs Form & View Settings

It may be what I need. Because in the above scenario, the doc’s title is set to one field only field1.
But I don’t see it in the doctype creation page. What version is it implemented? I’m on version 13.19