How to add this to a doctype (dashboard?)

Hello,

I don’t know what below is called. But I would like to some similar KPIs to one of my doctypes. Can anyone explain how to?

Hello,
If you check code of python server code
erpnext/buying/doctype/customer/customer.py (onload=> self.load_dashboard_info() ) : it load data into __onload accesible by js front code
erpnext/buying/doctype/customer/customer.js (refresh => set_party_dashboard_indicators() => erpnext/erpnext/public/js/utils.js => set_party_dashboard_indicators

Here you are
frm.dashboard.add_indicator(label,value, icon_colors);

2 Likes

Hi:

@FHenry Thanks! Very interesting!

Other way is just adding a HTML field to the doctype. In field Options you can use HTML and jinja syntax.

<b><label>Percent completed: </label></b>
<progress id="percent" max="100" value="{{doc.percent}}"> </progress>

Where {{doc.percent}} get data from other field.

If you need to assign content dinamically, you can use Client script and jquery

$( frm.fields_dict.yourhtmlfield.wrapper ).html(yourcontent)

or set_df_property

frm.set_df_property("yourhtmlfield", "options", `<H1>Hellooooo </H1>`);

Hope this helps.

1 Like