Hi Community,
i had Renamed Task to "Csp"doctype ; in csp doctype one childtable having “Action Items” i need while in Action items childtable if i create new row it should autocreate in Action item doctype and also when in “Action Item” doctype updates it should reflect in childtable “Action Items” i need solution i given code below i need small changes
def create_action_item(action_item_data, csp_name):
# Create a new Action Item in the "Action Item" doctype
action_item_doc = frappe.get_doc({
'doctype': 'Action Item',
'action_item': action_item_data.action_item,
'urgency': action_item_data.urgency,
'due_date': action_item_data.due_date,
'responsible_person': action_item_data.responsible_person,
'progress_status': action_item_data.progress_status,
'remarks_if_any': action_item_data.remarks_if_any,
'custom_csp_reference': csp_name, # Link to CSP reference (CSP ID)
'custom_status': action_item_data.status # Fetch status from child table
})
action_item_doc.insert(ignore_permissions=True)
# Loop through each row of the child table and create an Action Item if not already created
for item in doc.custom_action_item:
# Check if the Action Item already exists based on action item and due date
if not frappe.db.exists('Action Item', {'action_item': item.action_item, 'due_date': item.due_date}):
create_action_item(item, doc.name) # Pass CSP name (doc.name) as the reference for CSP
Thanks in Advance