Applying client script on Opportunity list hides status field

I am trying to apply a client script on the opportunity list in order to hide the ID, change column widths, etc.

However, applying any client script on the list, even

frappe.listview_settings[‘Opportunity’] = {
onload: function(listview) {
alert(“Script running”);
}
}

or even just

frappe.listview_settings[‘Opportunity’] = {
}

hides the coloured ‘status’ field. It still appears in the list settings, and it reappears when the client script is disabled. There is no other client script running on the Opportunity list or doctype.

Has anyone seen this behaviour before, or understand why it might be happening?

your “list” js script is overriding the entire default code . you should copy the entire code from here to your client script, and then make your changes .

Thank you, this is really helpful, and the status is back now.

I have one other issue, which is that now that I have copied this standard code, I can no longer see the value/‘opportunity_amount’ field, even though it is selected in list settings via UI. I have also tried adding it to the add_fields list at the beginning of the client script, but no luck.

Do you know how I can add fields in addition to this standard script?

you can update which columns to appear on list view by going to customize form , select the field and check in list view . or for your personal account on the list view click the 3 dots then list settings

Sorry, I have done more troubleshooting and the issue is larger than I thought. Basically, although I have set overflow-x to auto and there is a functional scroll bar, the 5th column set through the list settings gets cut off, no matter what column I put last.

The scroll bar works but stops before revealing the cut-off content, while the action buttons (heart icons, date) at the far right display fine.

My theory is that

hide_name_column: true

does not actually allow a 5th column to replace the ID field, even if it does remove it. Is that right, and is there a way around it? I will put my script below, but I think the name column is the issue.

frappe.listview_settings["Opportunity"] = {
	add_fields: ["title", "probability", "customer_name", "status", "opportunity_amount"],
	get_indicator: function (doc) {
		var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
		if (doc.status == "Quotation") {
			indicator[1] = "green";
		}
		return indicator;
	},
	hide_name_column: true,
    refresh: function (listview) {
        document.querySelectorAll('.list-row-col').forEach(function(col) {
            col.style.minWidth = '300px';
            col.style.maxWidth = '300px';
        });
        
        let main_container = document.querySelector('.frappe-list');
        if (main_container) {
            main_container.style.overflowX = 'auto';
        }
        document.querySelectorAll('.list-row-head, .list-row-container').forEach(function(col) {
            col.style.width = 'max-content';
        });
        document.querySelectorAll('.list-row, .level-right').forEach(function(col) {
            col.style.flex = '0';
        });
    }
};