Fetch data from linked Doctype onload document


I’m trying to fetch data from linked DocType and refresh this data when document is opened by one user.

In a custom script I’ve the following:

frappe.ui.form.on("Task", {
onload:function(frm) {
	frm.add_fetch("project", "first_date", "project_first_date");


Task is the doctype I want to display the first_date value from linked project. The field name in Task Doctype is project_first_date.

Everything is working fine when I create the task but I want to automatically refresh the value in Task Doctype when changes are made in linked Project Doctype.

Which is the best way to do it?

Thank you very much for your help.