I need automatically create new transaction while add childtable row in another transaction

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

Is this code working fine?

or

are you facing issue?

i need these fields Status{custom_status}-select field options In Progress
Completed,Remarks,if any{remarksif_any}- text-editor,Progress Status{progress_status}-percent these fields are in “Action Item” doctype when it value changes it should update(reflect) in “Action Items” childtable in CSP doctype i need solution
Thanks in Advance


it is creating Action Item transaction automatically but in csp doctype it is showing “Not Saved”

need solution.
Thanks in Advance