How to display the name of creator in the listview?

Hello,
In ErpNext, we can see the name of the user who created a particular record by applying the ‘Created by’ filter.
But I want the name of the user who created a particular record in the listview of any doctype.
This is possible with a client script for a particular doctype but I have no idea how to implement this thing for multiple doctypes because writing a client script for multiple doctypes is not the proper way.
If anyone has any idea about this let me know

Thanks in advance!

@Jignasa_Chavda
This below code might solve your’s

frappe.provide('custom_list_settings');

custom_list_settings.get_list_settings = function(doctype) {
    var list_settings = {};

    if (doctype === 'Sales Order') {
        list_settings.add_fields = ['created_by'];
        list_settings.format = function(row, doc) {
            row.columns[1].content = doc.created_by;
        };
    } else if (doctype === 'Purchase Order') {
        list_settings.add_fields = ['created_by'];
        list_settings.format = function(row, doc) {
            row.columns[1].content = doc.created_by;
        };
    }
    // add more conditions for other doctypes

    return list_settings;
};

$.extend(frappe.listview_settings, custom_list_settings);

Thank you.

2 Likes

In which file I have to write this code?

I tried this way but its not working for me
Here’s my code, I have written custom script for ‘Shift Type’ on form

frappe.ui.form.on("Shift Type", "validate", function(frm) {
    cur_frm.set_value("creator", frm.doc.owner);
});

@Jignasa_Chavda
You need to apply this code in which doc-type that you need to see this changes.

Did you mean in the custom script?

if anyone still needs a solution for this:
just go create a client script or a new js file with the name yourdoctype_list.js
follow the documentation on how to add script for list view here:

then add the following script to the onload event:

frappe.listview_settings['Item'] = {

	onload : function(listview) {
	    
	    cur_list.columns.push({
				type: "Field",
				df: {
					label: __("Created By"),
					fieldname: "owner",
				},
			});
		cur_list.refresh(true)
	}
    
}