Hi, I am trying to make the background of the box in report view to be a different color depending on the project, I cant seem to code.
frappe.ui.form.on('Delivery Note Line Item Tracking', {
refresh: function(frm) {
// Code related to refresh if any
},
formatter: function(value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
// Define your dynamic color map here
var color_map = {
"Project 1": "#5D8AA8", // Air Force Blue
"Project 2": "#F0F8FF", // Alice Blue
"Project 3": "#E32636", // Alizarin Crimson
"Project 4": "#EFDECD", // Almond
"Project 5": "#E52B50", // Amaranth
};
if (column.fieldname == "project_name" && color_map[data.project_name]) {
return `<div style='background-color:${color_map[data.project_name]};'>${value}</div>`;
}
return value;
}
});
This is what I thought up of so far and no errors, but it doesn’t run either. I believe I am not calling the class right?