Fetching a property value from the current User doctype

Hello devs,

I have customized my User doctype to have additional property (doc-field) and all my users now have this new property.

Now, what I want to accomplish is, when a user creates a particular doctype (Lets say ‘doctype:XZY’), I want that doctype XYZ to have a default read-only property field that fetches data from the User’s new created docfield property and set its value.

My question is how do I fetch this particular property’s value from the current user’s property/docfield’s list?

Thank you

Hi @abiccu,

If you have not a checked documentation so please check it.
Fetching Values From Master : Fetching Values From Master

Fetch value in a child table field from Master DocType: Example showing how to fetch value in a child table field from Master DocType

Thank You!

So I tried your option and entered this using client script option,

> frappe.ui.form.on('Insured Employee', {
> 	refresh(frm) {
> 		// your code here
>         frm.add_fetch('user','insuringcompany','company_covered')
> 	}
> })

To make my code clear, insuringcompany is the docfield that is in the User doctype, and I want to the fetch the insuringcompany doc-field and input it in the Insured Employee’s doctype > company_covered (docfield).

However, I wasnt able to get the value from the desired docfield using this. Am I doing something wrong?

Beginner in frappe here

Also please make note that I want to fetch the current User’s docfield data.
Thanks in advance

Insured Employee have a user field or not?

if have a user field then user below script:

Without use, only one blow line set then check it.


Thank You!

Hey NCP,

Insured Employee doesnt have a user field so I tried the latter option; however, company_covered is still not showing in the Insuring Company field, insuringcompany. Instead, the insuringcompany field just has the text ‘Insured Company’ in the UI.

Am I missing something? THanks again man