How to update Link field's value

I have a doctype Details which has a Link Field, say form referring to doctype Form. There’s a form.type field in Details.

If I change the value of type in my original doctype Form, how can I make sure the same is reflected in Details doctype ?



frappe.db.set_value("DocType", docname, "fieldname", value_to_set)

Yes, I know how to do it manually. But then what’s the point of link field if it’s just one time relationship ? I want the value to be reflected automatically when the change is made in one table. This just defeats the whole purpose of having an external relationship with another doctype.

Currently not available. If you think this is a valid point then create GitHub issue for it

Hi, can i use it in client side scripting (Custom Script of Doctype)…?

Yes this can be done with client side, except the code is kind of ugly.

//Code to update linked field + fields which fetch from linked field
// Does this by comparing modified timestamps
function auto_update_batch_link()
    var parent_doc;
    var temp_doc;
    parent_doc = frappe.db.get_doc("Doctype Name", cur_frm.doc.LinkedField)
    parent_doc.then((temp_doc) =>
		{if (temp_doc.modified >= cur_frm.doc.modified)
          //To reload fields that fetch from a linked field to have to toggle it
          //In this code resets the linked field, which will update the fetch fields
          var original_link = cur_frm.doc.LinkedField
 //Optional don't have to auto-save
					console.log('Auto-Updated Linked Field')


1 Like

Any updates? Is it possible now without custom script?