I have a doctype called “Contract” from that doctype I want to get the employee document from the current session user and then send it to create a new document of doctype “Commission Entry”. I want to know how to pass the employee document to a link field in the new doctype?
Hi,
Get the current session user’s employee document:
from frappe.utils import get_fullname
# Get the current user's full name
user_full_name = get_fullname()
# Get the employee document linked to the current user
employee = frappe.get_doc('Employee', {'employee_name': user_full_name})
Create a new “Commission Entry” document and set its link field to the employee document:
# Create a new "Commission Entry" document
commission_entry = frappe.new_doc('Commission Entry')
# Set the link field to the employee document
commission_entry.employee = employee.name
# Save the document
commission_entry.save()
Hope this will help you out.
Thank you