How to Change the Label of a Dashboard Indicator in Customer Doctype

Hi everyone,

I need help with changing the label of a dashboard indicator in the Customer doctype. Specifically, I want to change the label from “Annual Billing” to “YTD Billing.”

I’ve attached a screenshot for reference.

Could someone guide me on how to achieve this?

Thanks in advance!

code for this is written in /frappe-bench/apps/erpnext/erpnext/public/js/utils.js

@Sudhanshu check this Add or change indicators for dashboard

@Jeel Didn’t Helped. The solution was not clear

Hi @Sudhanshu,

Please apply the client script for the customer doctype.

frappe.ui.form.on("Customer", {
	refresh: function (frm) {
	    set_party_dashboard_indicators(frm);
	}
});

function set_party_dashboard_indicators(frm) {
	if (frm.doc.__onload && frm.doc.__onload.dashboard_info) {
		var company_wise_info = frm.doc.__onload.dashboard_info;
		if (company_wise_info.length > 1) {
			company_wise_info.forEach(function (info) {
				add_indicator_for_multicompany(frm, info);
			});
		} else if (company_wise_info.length === 1) {
			frm.dashboard.add_indicator(
				__("YTD Billing: {0}", [
					format_currency(
						company_wise_info[0].billing_this_year,
						company_wise_info[0].currency
					),
				]),
				"blue"
			);
			frm.dashboard.add_indicator(
				__("Total Unpaid: {0}", [
					format_currency(company_wise_info[0].total_unpaid, company_wise_info[0].currency),
				]),
				company_wise_info[0].total_unpaid ? "orange" : "green"
			);

			if (company_wise_info[0].loyalty_points) {
				frm.dashboard.add_indicator(
					__("Loyalty Points: {0}", [company_wise_info[0].loyalty_points]),
					"blue"
				);
			}
		}
	}
}

function add_indicator_for_multicompany(frm, info) {
    $('.flex-column.col-xs-6').hide();
	$('.flex-column.col-xs-6.new-dashboard').show();

	frm.dashboard.stats_area.show();
	frm.dashboard.stats_area_row.addClass("flex");
	frm.dashboard.stats_area_row.css("flex-wrap", "wrap");

	var color = info.total_unpaid ? "orange" : "green";

	var indicator = $(
		'<div class="flex-column col-xs-6 new-dashboard">' +
			'<div style="margin-top:10px"><h6>' +
			info.company +
			"</h6></div>" +
			'<div class="badge-link small" style="margin-bottom:10px"><span class="indicator blue">' +
			"YTD Billing: " +
			format_currency(info.billing_this_year, info.currency) +
			"</span></div>" +
			'<div class="badge-link small" style="margin-bottom:10px">' +
			'<span class="indicator ' +
			color +
			'">Total Unpaid: ' +
			format_currency(info.total_unpaid, info.currency) +
			"</span></div>" +
			"</div>"
	).appendTo(frm.dashboard.stats_area_row);

	if (info.loyalty_points) {
		$(
			'<div class="badge-link small" style="margin-bottom:10px"><span class="indicator blue">' +
				"Loyalty Points: " +
				info.loyalty_points +
				"</span></div>"
		).appendTo(indicator);
	}

	return indicator;
}

Output:

4 Likes

@NCP


In this we are adding Indicator.
What i want is either we rename exsisting Indicator
OR
Hide Annual Billing Indicator

I have already hidden the default indicator in the provided code.

@NCP
Thank you so much…
Its working FIne

is anyone also facing issue of multiple render of frm.dashboard ?

I tried the below code in refresh and download events and yet same issue
let percentage = Math.round(progress * 100);
frm.dashboard.add_progress(‘Budget Utilization’, percentage, percentage + "% of Total Budget is Used with a total of " + format_currency(spent_budget));