Avoid Global / Session Defaults On Field

On a custom DocType, is there a way to avoid having a field that is linked to Company be auto populated with the Global / Session Default?

If your fieldname is same as default then it will select default value. so change the fieldname like custom_company or target_company then it will not autofill the value

Thanks for the suggestion but I tested that and it didn’t solve the problem. Still populating the company field with the session default.

frappe.ui.form.on('test', {
    refresh: function(frm) {        
        if (frm.doc.company && frm.is_new()) {
            frm.set_value('company', '');
        }
    }
});

You can use Client Script to make the company field blank by default.

I had tried this already but it didn’t solve it. Continues to have the company field populated with the default.

Little more to add after playing around with this for a while now. After I do a Reload, it works the first time but then the second time I create a new record, it populates with the session default.

I added the following to my JavaScript file:

frappe.ui.form.on( "Sandbox", {
    onload: function ( frm ) {
        console.log( "onload called" );
    },

    refresh: function( frm ) {
        console.log( "refresh called" );
        if( frm.doc.company && frm.is_new() ){
            frm.set_value( "company", "" );
        }
    },

    company: function( frm ) {
        console.log( "company changed: " + frm.doc.company );
    }
} );

After I do a reload and create a new record, my company field is empty the first time as expected. The console output is:

onload called
refresh called
company changed:

But then if I go back to the list of my DocType and create new again, this is what happens:

onload called
refresh called
company changed:
company changed: Kwik-E-Mart

(Yes I’m using Simpson references for my testing)

Kwik-E-Mart is what I have set for my Session Defaults. If I change my Session Defaults company and repeat the above, same behavior except the other company is set.

The fact that this doesn’t happen the first time after the reload but then the rest is puzzling.

Anyone else see this behavior or have any other suggestions of things to try?