I created a new doctype: job applicant test, and put this serverside script in job_applicant_test it:
import frappe
from frappe.model.document import Document
class Jobapplicanttest(Document):
pass
@frappe.whitelist()
def insert(data):
try:
data = frappe.parse_json(data)
# doc = frappe.get_doc("job application test", data.get("docname")) # Correct the DocType name
doc = Jobapplicanttest(data.get("docname"))
for item in data.get("questions"):
row = doc.append("more_information", {})
row.question = item.get("question")
row.answer = item.get("answer")
doc.save(ignore_permissions=True)
frappe.db.commit()
return {"message": "success2"}
except Exception as e:
error_message = str(e)
frappe.log_error(frappe.get_traceback(), "insert_into_more_info_error")
return {"message": error_message}
this should add the new questions and answers to a table called more information. However, when i pass any docname to this code it tells me “Doctype not found”