Fetching the value from doctype and set it in the web forms field

I have a field named designation in the “Job Opening” Doctype. I have designed a web form for job opening doctype. I want the designation field value from the Job Opening doctype to be set in the web form’s designation field. I have tried the below code in the web form’s .

var design = frappe.db.get_value(“Job Opening”,frm.doc.designation,“designation”)
frappe.web_form.set_value([“designation”], design)

I’m getting this error.

new?job_title=HR-OPN-2024-0092:4082 TypeError: Cannot read properties of undefined (reading ‘get_value’)
at frappe.init_client_script (new?job_title=HR-OPN-2024-0092:4077:24)
at sr.make (web_form.js:37:39)
at i (webform_script.js:45:12)
at webform_script.js:10:39
at website.js:282:4
at Array.forEach ()
at Object.trigger_ready (website.js:281:23)
at HTMLDocument. (website.js:634:9)
at HTMLDocument.dispatch (jquery.js:5135:27)
at Ut.handle (jquery.js:4939:28)

Note: The document name of the Job Opening is HR-OPN-2024-0092

Help me out to clear in this. Thanks in advance.

1 Like

Use await for get values from database

1 Like

Thank you. We got one solution

For getting that value, we used after_load with delay time. So this error has overcome.

1 Like