Your code for frappe.listview_settings['HD Ticket'] looks correct at first glance, but the issue where only "Open" shows a color and the rest do not, is likely due to one of the following reasons:
1. Status Value Mismatch
The most common cause is that the doc.status values do not exactly match the cases in your switch statement. For example, maybe your status is "In progress" (lowercase "p") instead of "In Progress", or there are extra spaces.
How to Debug:
Add a console.log(doc.status) before the switch to see what values are coming in:
get_indicator: function (doc) {
console.log("Status:", doc.status); // Add this line
switch (doc.status) {
case "Open":
return [__("Open"), "red", "status,=,Open"];
case "In Progress":
return [__("In Progress"), "orange", "status,=,In Progress"];
case "On Hold":
return [__("On Hold"), "yellow", "status,=,On Hold"];
case "Resolved":
return [__("Resolved"), "blue", "status,=,Resolved"];
case "Closed":
return [__("Closed"), "green", "status,=,Closed"];
default:
return [__(doc.status), "gray", "status,=," + doc.status];
}
}
Check your browser console for the actual status values.
2. Translation Issues
If you are using translations (__()), make sure the status values in your database are in English (or the language you are matching in the switch). If not, the switch will not match.
3. Custom CSS or Theme
Sometimes, custom CSS or a theme can override the indicator colors. Check if your theme is affecting the indicator colors.
4. Frappe Version
Some older versions of Frappe have bugs with listview indicators. Make sure you are on a recent version.
How to Fix
Option 1: Normalize Status
Make your switch case insensitive and trim spaces:
get_indicator: function (doc) {
let status = (doc.status || "").trim().toLowerCase();
switch (status) {
case "open":
return [__("Open"), "red", "status,=,Open"];
case "in progress":
return [__("In Progress"), "orange", "status,=,In Progress"];
case "on hold":
return [__("On Hold"), "yellow", "status,=,On Hold"];
case "resolved":
return [__("Resolved"), "blue", "status,=,Resolved"];
case "closed":
return [__("Closed"), "green", "status,=,Closed"];
default:
return [__(doc.status), "gray", "status,=," + doc.status];
}
}
Option 2: Use If-Else
If you prefer, use if-else for more flexibility:
get_indicator: function (doc) {
let status = (doc.status || "").trim().toLowerCase();
if (status === "open") return [__("Open"), "red", "status,=,Open"];
if (status === "in progress") return [__("In Progress"), "orange", "status,=,In Progress"];
if (status === "on hold") return [__("On Hold"), "yellow", "status,=,On Hold"];
if (status === "resolved") return [__("Resolved"), "blue", "status,=,Resolved"];
if (status === "closed") return [__("Closed"), "green", "status,=,Closed"];
return [__(doc.status), "gray", "status,=," + doc.status];
}
Summary
- Check the actual values of
doc.status.
- Make your matching case-insensitive and trim spaces.
- Check for translation or theme issues.
Try the debug step first and you’ll likely find the mismatch!