Virtual Fields Not Showing Value When Getting Fetched From Different Document After Getting Saved

I am getting one serious issue.

In this , FF RFQ is a link field and other fields such as POL, POD, INCOTERM are fetched from (FF RFQ-2) which is fine before creating. These 3 fields are virtual fields.

After it is created it is also fine and shows like this…

But then as soon as I revisit the doc… the fields are not getting fetched…

1 Like

@revant_one Can you see this once? Is it Framework error or am I doing something wrong?

Can anybody check on this?
This is really very frustrating for this.

If I understood correctly, you were trying to fetch from virtual field, which is not possible.

Virtual fields are designed to display values, fetched from some other source, and values are never stored in or for virtual field; you need to fetch these values again from the same data source.


H. S. Rai

1 Like

No I am not fetching from Virtual Fields

I am fetching from normal fields.

The fields to which data is getting populated is virtual. Like a calculated field. But source fields are not virtual

@hsrai

Try creating one Doctype Named Test-1 and then have one docField Test

Create another Doctype Test-2 and have one link field of Test-1 to reference Doctype Test-1 and have one more field ‘Test-2’ . Make it Read-Only, Virtual and Fetch from Test-1.Test field (All this can be done from Desk UI)

Now create one document in Test-1. Then go to Test-2. It will Fetch details. You can save it. But after refreshing its not showing

When I am saying Fetch From, I mean the Desk UI configuration like this

Please look into this

I tested and it worked fine for for me on Frappe Framework: v14.53.1


H. S. Rai

I am on Frappe v15.4.1.
This issue is there for me.

Tested on Frappe Framework: v15.4.1.

Working fine. I tested on Non-submitable docType, as per out flow / instructions of Test-1 and Test-2.


H. S. Rai

1 Like

Have you tried refreshing and revisiting the DocType again?
When I am creating it shows correct, but as soon as I revisit or refresh it, it shows empty field in me.

You are right.

In both V14 and V15, behaviour is the same. It is not there.


H.S.Rai

Okay,
I have raised issue on the github. Hope somebody solves it quick.

1 Like

I noticed that:

[ ] Fetch on Save if Empty
If unchecked, the value will always be re-fetched on save.

A check box, with above explanation.

Which event will fetch this value?

Above explanation suggest that it is on “Save”.

You need it “On Load”.

Try JavaScript.


H. S. Rai

1 Like

If somehow you make it “Not saved”, and when you save it, then value appears there.

IMO, it works on the change of linked field, and “On Save”.


H. S. Rai

1 Like

So what is the exact solution for it? Can you help me with your snippet?

I can do this in javascript but then I have to do it in list-view as well because there also value is not showing.

I just fetched the doc through fappe.db.get_doc() and whatever fields I needed of that doc in my current frm, just putting that.

linked_doc = frappe.db.get_doc(‘Doctype’, docname)

onload(frm)
{
frm.doc.field = linked_doc.field
}

2 Likes

I have the same problem: virtual fields don’t show the data after being saved. I’m new in frappe (new in programming too) and I can not figure it out how to solve it with your solution. Could you explain a little bit more or is there any other solution?
Thanks,