IndexError('list index out of range')


the error appear when the condition if payment_status == “ACSC” is ture
but in another condition every thing is run well
?!

Hi @manal_erpnext ,

Try this?

if payment_status == "ACSC":
    doc.workflow_state = "Submit"
    doc.submit()

elif payment_status == "RICT":
    doc.workflow_state = "Rejected"
    doc.save()

frappe.db.commit()
    "message": [
        -3,
        "WorkflowPermissionError('Workflow State transition not allowed from <strong>Write</strong> to <strong>Draft</strong>')"
    ],
    "_server_messages": "[\"{\\\"message\\\": \\\"Workflow State transition not allowed from <strong>Write</strong> to <strong>Draft</strong>\\\", \\\"title\\\": \\\"Message\\\", \\\"indicator\\\": \\\"red\\\", \\\"raise_exception\\\": 1, \\\"__frappe_exc_id\\\": \\\"88eea4ad4d3357bd380c2044c21e7c6bcf4822956adb62643d4e5e3b\\\"}\"]"
}

Hi @manal_erpnext ,

This issue occurs because the transition from ‘Write’ to ‘Draft’ is not allowed in the workflow. You can resolve this by adding the transition in the workflow.