Not able to see colors in List View

Hi,

frappe.listview_settings['Lead'] = {
	add_fields: ["lead_status"],
	get_indicator: function (doc) {
		return [__(doc.lead_status), {
			"Active": "green",
			"Non-Active": "red",
			"Potential": "orange"
		}[doc.lead_status], "lead_status,=," + doc.lead_status];
	}
};

This is my code, which I am using for a select field called lead_status.
Colors are shown in the document itself but not being shown in the list view.


But not here:

Any idea about this?

Regards
Ruchin Sharma

1 Like

Does anybody have any idea about this

Itā€™s working for me, where did you put this code? It should be named lead_list.js and put in

erpnext/erpnext/crm/doctype/lead/lead_list.js

@netchampfaris
It was working for me earlier but suddenly it stopped working. I donā€™t know what happend. Apart from that, I donā€™t want to change the original code by editing the original source file.

BTW here I have written my code:

Regards
Ruchin Sharma

@netchampfaris
I have added the code in the said file but the problem is it is coming like this:

Which will create confusion to user on which name they need to filter.

Any idea about this?

Regards
Ruchin Sharma

Try unchecking the In List View option of Status field in Customize Form

@netchampfaris
I did try for the same, but after un-checking the status field the color goes and the looks like with the colors shown in the Lead Status.

Regards
Ruchin Sharma

Hi,
I am still not able to see the colors.

Even, I tried hooks too but still it looks like this only.

frappe.listview_settings['Lead'] = {
	add_fields: ["lead_status"],
	get_indicator: function(doc) {
		if(doc.lead_status=="Active") {
			return [__("Active"), "green", "lead_status,=,Active"];
		} else if(doc.lead_status=="Non-Active") {
			return [__("Non-Active"), "red", "lead_status,=,Non-Active"];
		} else if(doc.lead_status=="Potential") {
			return [__("Potential"), "orange", "lead_status,=,Potential"];
		}
	}
};

Regards
Ruchin Sharma

Hi,

in my case it is working like this, the only difference I can see is the ===

	    if(doc.type==="Bank Transfer") {
	        if(doc.status_invoice==="Wallet"){
	        	return [__(doc.status_invoice), "grey", "status_invoice,=," + doc.status_invoice];
	        }
	        else if(doc.status_invoice==="Remittance"){
	        	return [__(doc.status_invoice), "green", "status_invoice,=," + doc.status_invoice];
	        }
	        else if(doc.status_invoice==="Unpaid"){
	        	return [__(doc.status_invoice), "red", "status_invoice,=," + doc.status_invoice];
	        }
	        else if(doc.status_invoice==="Stopped"){
	        	return [__(doc.status_invoice), "orange", "status_invoice,=," + doc.status_invoice];
	        }
		}

@Pau_Rosello_Van_Scho
I have updated my code as per your code but still it is not showing the colors in the list view.

frappe.listview_settings['Lead'] = {
	add_fields: ['lead_status'],
	get_indicator: function(doc) {
		        if(doc.lead_status==="Active"){
	        	return [__(doc.lead_status), "green", "lead_status,=," + doc.lead_status];
	        }
	        else if(doc.lead_status==="Non-Active"){
	        	return [__(doc.lead_status), "red", "lead_status,=," + doc.lead_status];
	        }
	        else if(doc.lead_status==="Potential"){
	        	return [__(doc.lead_status), "orange", "lead_status,=," + doc.lead_status];
	        }
	        else{
	        	return [__(doc.status), "grey", "status,=," + doc.status];
	        }
	}
};

Anyone, any idea about why it is not working. One thing I want to mention here is lead_status is a custom field.

Regards
Ruchin Sharma

The last options is to debug the function. Put debugger; at the start of the get_indicator function and open the Dev Tools on the browser. If you go step by step you should be able to find the error.

If this is a public ERPNext instance I could help you with this.

Regards!

@Pau_Rosello_Van_Scho
Thanks for the hint given, but to be honest. I am not able understand it.
Colors are coming inside the form but not in the List View.

Regards
Ruchin Sharma

@ruchin78,

You can use the column render to format the column according to your requirement.
Please check the https://github.com/frappe/frappe/blob/develop/frappe/core/doctype/feedback_request/feedback_request_list.js#L5

Thanks,
Makarand

@makarand_b
I tried this, but it is still not working.

Did I miss something?

frappe.listview_settings['Lead'] = {
	colwidths: {
		subject: 4,
	},
	column_render: {
		lead_status: function(doc) {
			html = ""
			if(doc.lead_status ==="Active")
			{
				html += repl("<span class='indicator %(color)s'></span>", 
					{ color:"green"})
			}	
			else if(doc.lead_status === "Non-Active")
			{
				html += repl("<span class='indicator %(color)s'></span>", 
					{ color:"red"})
			}
			else if(doc.lead_status === "Potential")
			{
				html += repl("<span class='indicator %(color)s'></span>", 
					{ color:"orange"})
			}
			return html
		}
	}
}

Regards
Ruchin Sharma

Hello @ruchin78

Did you find a solution for your problem?

I am noticing that we are able only to add indicator for status field because when we add another indicator for another field, the Status field in the listview will act based on latest indicator and not first one. Also, I do not know what is the benefit of writing add_fields in the listview_settings, why?

I tried the below code in the trip_order_list.js and I obtained the below image for listview which is not the required:

frappe.listview_settings[ā€˜Trip Orderā€™] = {
add_fields: [ā€œgrand_totalā€, ā€œoutstanding_amountā€],
get_indicator: function(doc) {
if(flt(doc.outstanding_amount)===0) {
return [(ā€œPaidā€), ā€œgreenā€, ā€œoutstanding_amount,=,0ā€];
} else if (flt(doc.outstanding_amount) > 0) {
return [
(ā€œUnpaidā€), ā€œorangeā€, ā€œoutstanding_amount,>,0ā€];
}
}
};

frappe.listview_settings[ā€˜Trip Orderā€™] = {
add_fields: [ā€œorder_statusā€],
get_indicator: function(doc) {
return [__(doc.order_status), {
ā€œIn Progressā€: ā€œblueā€,
ā€œAssignedā€: ā€œorangeā€,
ā€œScheduledā€: ā€œorangeā€,
ā€œDoneā€: ā€œblueā€,
ā€œCancelledā€: ā€œredā€,
}[doc.order_status], ā€œorder_status,=,ā€ + doc.order_status];
}
};

And the result was:

And it is not the needed result !
Any advise?

Regards
Bilal

Does it work? I tried but it does not.

Any Update??

Any Update?