get_indicator in list view __unsaved property is always undefined

In list view of a doctype get_indicator is called in every row but I tried to print the value of doc.__unsaved its always undefined. Why? How to check if the row is not yet save?

frappe.get_indicator = function(doc, doctype) {
        console.log(doc.__unsaved); # <============= this is always undefined
	if(doc.__unsaved) {  # <============= this is always undefined
		return [__("Not Saved"), "orange"];

	if(!doctype) doctype = doc.doctype;

	var _get_indicator = frappe.listview_settings[doctype]
			&& frappe.listview_settings[doctype].get_indicator,
		is_submittable = frappe.model.is_submittable(doctype),
		workflow_fieldname = frappe.workflow.get_state_fieldname(doctype);

	// workflow
	if(workflow_fieldname) {
		var value = doc[workflow_fieldname];
		if(value) {
			var colour = {
				"Success": "green",
				"Warning": "orange",
				"Danger": "red",
				"Primary": "blue",
			}[locals["Workflow State"][value].style] || "darkgrey";
			return [__(value), colour, workflow_fieldname + ',=,' + value];

	if(is_submittable && doc.docstatus==0) {
		return [__("Draft"), "red", "docstatus,=,0"];

	if(is_submittable && doc.docstatus==2) {
		return [__("Cancelled"), "red", "docstatus,=,2"];

	if(_get_indicator) {
		var indicator = _get_indicator(doc);
		if(indicator) return indicator;

	if(is_submittable && doc.docstatus==1) {
		return [__("Submitted"), "blue", "docstatus,=,1"];

	if(doc.status) {
		return [__(doc.status), frappe.utils.guess_colour(doc.status)];

Which doc are you passing?

Hello :slight_smile: @rmehta I tried it in journal entry list, quotation list and quotation edit. I think its all doctype. This from /frappe-bench/apps/frappe/frappe/public/js/frappe/model/indicator.js . I just put console.log(doc.__unsaved); in frappe.get_indicator = function(doc, doctype). I always get undefined in doc.__unsaved see screenshoot.

My question is why put a condition in frappe.get_indicator which is always undefined? and in this function how to check if its save or not?

       if(doc.__unsaved) {  # <============= this is always undefined
		return [__("Not Saved"), "orange"];
1 Like

@ccfiel this is good :smile: . You want to send a PR?

@rmehta I want to but I can not figure it out how to check if the doc is not save in frappe.get_indicator = function(doc, doctype) because doc.__unsaved is undefined. maybe you have a tip? :smile:

@ccfiel … Ok, this is because doc is always served fresh from the list. Add this:

if(locals[doc.doctype] && locals[doc.doctype][]) {
  doc.__unsaved = locals[doc.doctype][].__unsaved;

@rmehta I tried to dissect your code if the condition part


locals is defined see screenshot for values
doc.doctype has value
locals[doc.doctype] is undefined.
locals[doc.doctype][] also this one is undefined.

So your code is ways False. :frowning:

ah, maybe its does not append the doctype.

You might have to use cur_list.doctype if doc.doctype is not set

if(!doc.doctype && cur_list) doc.doctype = cur_list.doctype;
if(locals[doc.doctype] && locals[doc.doctype][]) {
  doc.__unsaved = locals[doc.doctype][].__unsaved;

Edit: fixed typo

@rmehta doc.doctype has a value we do not have e problem with it. The problem is locals[doc.doctype] is undefined locals variable dic has no “Subject Teacher” element. “Subject Teacher” is the value of doc.doctype :smile:

Then it can’t be unsaved!

Edit: All unsaved, loaded docs are present in locals

@rmehta let me dig the source again :slight_smile: to understand whats going on :smiley: Im confuse :frowning: