How to re-assign the default value of a Frappe docfield from a script

Hello all

1 I’m using a client script to manage the “Display Depends On” aspect of various docfields.

Screenshot from 2023-03-25 14-58-14

I want to reset the Category docfield, which is of Select field type, to it’s default value when the Attached file is cleared. The default is defined as part of the docfield’s definition.

Screenshot from 2023-03-25 15-27-50

How can I re-assign this default value, “Not Selected”, when the docfield is no longer hidden, in other words when it is displayed again. Obviously, I can simply assign the literal string, but I’d like to access, and re-assign, it’s default programmatically. Something such as

frm.doc.category.setDefault();

or

frm.doc.category = frm.doc.category.getDefault();

2 Also, how can I access the “Reload File” and “Clear” events?

category: function(frm) {
        if (frm.doc.category === "Not Selected") {
            frm.set_df_property("attach", "hidden", 1);
            frm.set_df_property("upload", "hidden", 1);
        } else {
            frm.set_df_property("attach", "hidden", 0);
//The following is incorrect, but I need to tie into the "Clear" event or call the method
            frm.doc.attach.clear();
        }
},

Thanks so much

did you find an answer for this

No, I’m afraid not…, sadly…