Customize linked customer in New Adress

Following situation:

On the quotation, I have added a second customer field (Disposal Customer) and an according second address field (Disposal Address).

I would like to have a newly created address, when initiated from this searchbox, automatically linked to the Disposal Customer.

Right now the new address is always linked to the original customer of the quotation, which is wrong in this scenario…

Any ideas how to solve that?

I think the link is created within frappe/address.js at develop · frappe/frappe ( , but I couldnt find a way to adapt that. Any options?

I do manage to put custom data into “normal” data fields within the address, e.g.

script is on the quotation, to allow the disposal address to receive onto the “replace link”.

	onload: function (frm) {
	const so = frm.get_docfield("disposal_address");
	so.get_route_options_for_new_doc = () => {
		if (frm.is_new()) return;
		return {
			"replace_link": frm.doc.disposal_customer

but I cannot manage to put an entry into the “Links” table…

I like to solve my own issues too… :wink:

in addition to the code from above on the quotation, I added the following code to address:

frappe.ui.form.on("Address", {
	refresh: function(frm) {
		if(frm.doc.replace_link) {
			frm.add_child('links', {
				link_doctype: 'Customer',
				link_name: frm.doc.replace_link

quite hacky… but seems to work. need to do some more testing…