Custom List Javascript Code is not Working

Nothing seems to be working:

  • add_fields
  • get_indicator
  • doc seems undefined in refresh

debugging:

  • console log shows: payment requisition list
  • refresh is running - so the code is running


The status should be grey but its red

Code:

console.log("payment requisition list");

frappe.listview_settings["Payment Requisition"] = {
	add_fields: ["total"],
    get_indicator: function (doc) {
		const status_colors = {
			"Quotations Required": "grey",
			"Submitted to Accounts": "grey",
			"Employee Revision Required": "grey",
			"Awaiting Internal Approval": "grey",
			"Awaiting Director Approval (1)": "grey",
			"Awaiting Director Approval (2)": "grey",
			"Payment Due": "grey",
			"Capture Expenses": "grey",
			"Revision Requested": "grey",
			"Expense Revision": "grey",
			"Accounts Approval": "grey",
			"Cancelled": "grey",
			"Rejected": "grey",
			"Closed": "blue",
            "Approved": "grey",
            "Ready for Submission": "grey",
            "Payment Completed": "blue"
		};
		return [__(doc.workflow_state), status_colors[doc.workflow_state], "workflow_state,=," + doc.workflow_state];
    },
    refresh: function(listview, doc) {
        console.log(listview.data, doc);
    }
}

If you have a workflow, then get_indicator will not work on the doctypes that have a workflow. You can define colors in workflow states.

1 Like

That should be the issue, I wanted to dynamically assign the colors using some logic. But aside this, other functions arent working like add_fields. The only thing working is refresh/ onload

You can solve this by setting the “Don’t Override Status” button to True in the Workflow.