How does the "Fetch From" in Doctype Custom Field work?

Here’s the documentation for various options on the Custom Field modal:

  1. Fetch From: When you want your Custom Field to be ‘Link Field’, you would be required to specify the Form to which this Field is to be linked. E.g., you want to create a Custom Field ‘Project’ in the DocType ‘Item’. You would be required to enter to specify your Field Type as ‘Link’ and enter ‘Project’ in the Fetch From Field to ensure that the Field is updated with the list of all the required DocTypes.
  2. Fetch If Empty: This check-box will ensure that this Field will be not overwritten based on Fetch From if a value already exists.
  3. Default Value: Enter the default value of the Field which you would want to be fetched for this Field.

I’m trying to auto-name a Task based on a “Project Key”, which is a custom four-character Identifier for projects. Similar to the way Jira works.

I’ve defined a custom field “Project Key” in the Project doctype.

Now, when I create a task associated with that Project, I’d like the Project link to be automatically filled in, but I’d also like a “Project Key” field to be populated from the same project either when the Task is created, or even better, have the Project Key get updated any time the Project fields gets populated or changed.

My intuition is that the “Fetch From” field should be able to retrieve this value with something like this:

You probably know that this has no effect and the Project Key field remains empty.

Upon reflection, this makes some sense, since the “Fetch From” field may not know which Project to pull the code from.

How can I retrieve the Project Key from the linked Project automatically upon task creation?

The end goal, is to be able to use the Project Key to name the task, so a task attached to project with a key “RAIC” would use an auto name formula to name the task with the pattern RAIC-0001.

Hi there,

I’m not at my computer to test, but I believe it should work if you set the link option as project.project_code rather than Project.project_code. You use the variable name (not the label) to define the link.

If that doesn’t work, I’ll take a look when I get back to the office. If I’m understanding you correctly, what you are trying to do is possible.


Thank you, @peterg, you are my savior.

That works like a charm!

Do you know if there is a way to find out easily what variables are available in a given dialog field?

I believe that you can fetch any field in any document that is linked to the current doc in a link field. In v14, the empty text field here has been replaced with a set of drop-down select fields in the Customize Form tool, so it’s all a bit easier.

1 Like

What can be the reason for data not being fetched even though the fetch syntax is correct, the link field is there … etc ?

But that drop-downs doesn’t list any doctypes. Also, the doctype i want list in the Fetch From field is in the same module i want to link the field. Could you please help in this scenario. I’m a newcomer to Frappe

This is working:


This is not working:


Fields of “DPP Content2” are not showing in the drop-down.

However, same application running on another machine is working. These has been tested on frappe version-14 and develop both.

Someone help please, if you resolved such issues earlier.

1 Like

It’s not working with me