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?
Eto
May 29, 2023, 5:10pm
2
have DocType A and Z any link between ? i think only linked DocType ( Tables ) can use in option to fetch from.
NCP
May 30, 2023, 4:57am
3
Hi @charleslcso ,
Please check the whole post.
Maybe, it helpful for you.
Another Thread:
Hi @BalaV ,
Please apply the client script for it.
Here, we share the syntax, so please set your doctype and field according.
frappe.ui.form.on('SecondDocType', {
refresh: function(frm) {
// Fetch values from FirstDocType based on prospect_id
frappe.db.get_value('FirstDocType', {'prospect_id': frm.doc.prospect_id}, 'field_name', function(value) {
// Update field in SecondDocType with the fetched value
frm.set_value('field_name', value.field_name);
…
I hope this helps.
Thank You!
1 Like
NCP:
Another Thread:
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
:
Image cannot be set.
In order to set an image we might not use frm.set_value()…
I am studying other methods, and I found:
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
NCP
May 31, 2023, 4:38am
5
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?
NCP
June 1, 2023, 5:02am
7
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