Custom Field Color

Hello,

It is possible from Custom Script to change the color of a custom field from a custom doctype?

Custom field : nr_apt
Custom doctype : sesizari

Thanks!

Any idea?

What do you mean by changing the color? Are you referring to the Color field or Status indicator color?

Which one is the easiest to implement it?

The best is status indicator but also an static Color Field.

This is how the Status field color can be customized:

https://github.com/frappe/erpnext/blob/develop/erpnext/manufacturing/doctype/production_order/production_order_list.js

Good Thanks !

And the color field?

RIght now the color field is only used for Gantt and Kanban, maybe we should enable it for other views as well.

@Florea_Andrei

If you want to pick a color then you can go for color field

how can i do this? any idea?

To change color of the field you can go with what @netchampfaris suggested you can refer the above instead of doc.status you use our own custom field

And this needs to be added in Custom Script?

I have added to add the below script in custom script

frappe.ui.form.on(‘Sesizari’){validate: function(frm) {
if(doc.tip_colaborare===“Deschis”) { return [(“Contract in Derulare”), “green”];
} else {
return [
(doc.tip_colaborare), {
“Reziliat”: “red”,
“Contrat in Derulare”: “green”,
“Succesiv 12 luni”: “orange”,

		}[doc.tip_colaborare], "status,=," + doc.tip_colaborare];
	}
}

};

and I get this erorr :slight_smile:

SyntaxError: Unexpected token {
at Class.setup (http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:2616:18)
at _f.Frm.setup (http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:172:22)
at _f.Frm.refresh (http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:441:9)
at Class.load (http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:87:33)
at http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:82:7
at Object.with_doc (http://erp.grupelectroinstal.com:98/assets/js/desk.min.js?ver=1510315981.0:5401:4)
at Class.show_doc (http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:65:16)
at http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:24:8
at Object.with_doctype (http://erp.grupelectroinstal.com:98/assets/js/desk.min.js?ver=1510315981.0:5340:17)
at Class.make (http://erp.grupelectroinstal.com:98/assets/js/form.min.js?ver=1510315981.0:20:17)