I am creating Add-Ins for Ms-Word and there is one situation where I need to check the file name and set custom add-ins button to enable/disable regarding that?

I tried many ways to solve it but they don't work for me.

**The code is given below.**

```
Office.initialize = function () {
    // Office is ready
    await Word.run(function (context) {
        loadFileName();
        return context.sync();
    })
        .catch(function (error) {
            console.log("Error: " + error);
            $('#errorDiv').text(error);
            if (error instanceof OfficeExtension.Error) {
                console.log("Debug info: " + JSON.stringify(error.debugInfo));
            }
        });
};

Office.onReady(async () => {

});

function loadFileName() {
    var a = "1";
    var name = "";
    Office.context.document.getFilePropertiesAsync(null, (res) => {
        if (res && res.value && res.value.url) {
            a += "2";
            name = res.value.url.substr(res.value.url.lastIndexOf('\\') + 1);
            a += "2.1";
            a += name;
            $('#errorDiv').text(a);
            test(name, a);
        }
    });

}
function test(name, a) {
    a += "test";
    $('#errorDiv').text(a);
    if (name != null && name != "" && name.toLowerCase().startsWith("cleancopy")) {
        a += "3";
        Office.ribbon.requestUpdate({
            tabs: [
                {
                    id: "Contoso.Tab1",
                    controls: [
                        {
                            id: "Contoso.FunctionButton",
                            enabled: false
                        },
                        {
                            id: "Contoso.TaskpaneButton",
                            enabled: false
                        },
                    ]
                }
            ]
        });
        a += "4";
    }
    $('#errorDiv').text(a);
}

```

Currently Not Working with code and this method is calling when I click on the Task pane button.

If anyone has an idea then It helps me a lot.