Add Contact_html & Address_html

Hello! Did not find the answer on the forum.

Please tell me how to make the fields work in the created DocType Contact_html & Address_html


I read all the articles where this topic is mentioned, but have not yet understood.
Thanks.

Hi,
Below is the script in which :

1.) Company Billing Address is field with Link type(linked to Address).
2.) Company Billing Address Display is Small Text type field

company_billing_address: function(frm){
if(frm.doc.company_billing_address !== undefined){
frappe.call({
method: ‘frappe.contacts.doctype.address.address.get_address_display’,
args:
{
‘doctype’ : ‘Address’,
‘address_dict’ : frm.doc.company_billing_address
},
callback: function(response){
cur_frm.set_value(“company_billing_address_display”,response.message);
cur_frm.refresh_fields(“company_billing_address_display”);
}

        });
    }else{
        cur_frm.set_value("company_billing_address_display","");
        cur_frm.refresh_fields("company_billing_address_display");
    }
}

Hope this will help.
Thanks

I apologize for my incompetence
Please tell me where to insert such a script
I’ll try to figure it out, and rewrite it under my DocType
Thanks in advance.

Hi,

Write this in Client Script of respective Doctype.

Thanks

hello,

you can add a field which is a link type and create another field to display the address the type will be a small text and then add a fetch from value to it and it will fetch the address automatically :slight_smile:

Since you have experience, I would like to ask you for help in setting up DocType - Respondent on our website.
ready to discuss possible gratitude.

Hi I was able to resolve.

JS File:

frappe.ui.form.on('Sample', {
    refresh: function(frm) {
        frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Sample'};
        frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal);
        if(!frm.doc.__islocal) {
            frappe.contacts.render_address_and_contact(frm);
        } else {
            frappe.contacts.clear_address_and_contact(frm);
        }   
    }
});

PY File:

from __future__ import unicode_literals
from frappe.model.document import Document
import frappe
from frappe import _
from frappe.contacts.address_and_contact import (
    delete_contact_and_address,
    load_address_and_contact,
)

class Sample(Document):
	def onload(self):
		“”“Load address and contacts in __onload“””
		load_address_and_contact(self)

I hope this will help :slight_smile: