Is it possible to show DocA's DocField in DocB's Form?

I have a DocType named Doc Type A. In there I have multiple documents, with names, say, Doc 1, Doc 2 and etc. Each Doc 1, Doc 2 and etc has a DocField of type Image named Field.

I have another DocType named Doc Type Z, and when I fill in the form when creating Doc Type Z, I want one of its fields to show Doc 1’s particular Field.

Don’t think I can use Options. Likely to work is Fetch From, of which I can’t get it to work:

Doc Type A.Doc 1.Field

or

doc_type_a.doc_1.field

won’t work.

Is this possible at all?

have DocType A and Z any link between ? i think only linked DocType ( Tables ) can use in option to fetch from.

Hi @charleslcso,

Please check the whole post.
Maybe, it helpful for you.

Another Thread:

I hope this helps.
Thank You!

1 Like

Nice! To be precise, Doc Type A’s image link can be retrieved and pasted into DocField of Type data. This at least shows retrieval is working.

I can’t set value for Type Image yet.

Here is the detail for Doc Type A:

This is Doc Type Z:

Screenshot 2023-05-31 at 9.50.57 AM

Image cannot be set.

Screenshot 2023-05-31 at 9.54.33 AM

In order to set an image we might not use frm.set_value()…

I am studying other methods, and I found:

  • frm.set_df_property()

I’m trying to figure out how to do it using https://docs.erpnext.com/docs/v12/user/manual/en/customize-erpnext/custom-scripts/make-read-only-after-saving

Hi @charleslcso,

We did set like:
Using fetch from, Item Image set in Test DocType.

Item:
Field → Image
Field Type → Attach Image

Test DocType Configuration:

Output:

I hope this helps.
Thank You!

1 Like

Thank you very very much.

Do you think it is possible to show the Image, not the file path?

Hi @charleslcso,

Configure it.

Add more one field like Image View and Type is Small Text. Also, Make a read-only field.

Then apply the client script:

frappe.ui.form.on('Test Child Table', {
	item: function(frm, cdt, cdn) {
	    var row = locals[cdt][cdn];
	    var iv = '<img src='+row.image+' style="width:25%;">';
        frappe.model.set_value(cdt, cdn, 'image_view', iv);
	}
});

Please set your field and doctype according.

Output:
When you select the item then item image will appear.

I hope this helps.
Thank You!

1 Like