How do I remove Saturday and Sunday from a Date field

hey Margarita,

i have been trying a few different things but cant get it to work. please see my code below.

function compareNameToCurrentUser(){

    pnp.sp.web.currentUser.get().then(function(user){

        compareNameToUser(user.LoginName);

        getUserProvince(user.LoginName);

    });//pnp.sp.web.currentUser

}//compareNameToCurrentUser()

function getUserProvince(name){

    var filter = "Empl/Name eq '"  + name.replace('#', '%23') + "' and YearforPlumsail eq '" + new Date().getFullYear() + "'";

    pnp.sp.web.lists.getByTitle("PTO-Admin").items.filter(filter).get().then(function(items){

return items[0].Province 

        }).then(function(Province){

        pnp.sp.web.lists.getByTitle('Holidays').items.filter('Province eq ' + Province).get().then(function(dates){

                //code to diable dates

                //trying to see if the province is being returned. 

                fd.field('TestDays').value = items[0].Province;

        })

    });

}

fd.spRendered(function () {

   //Employee Balances and name check

    compareNameToCurrentUser();

        getUserProvince(value.Key);

});

@r_pat,

What does compareNameToUser function do?

Why don't you want to filter the list by the user ID?

That function help me get the current login In user.
Then it compares and the name and current year with data from another list and gets data. Then I assign it to some of the fields.

Nikita helped me with that. I can send it to you if you like.

@r_pat,

The value.Key is not defined and that breaks the code.

If you need to get the province of the user selected in the Person or Group field, the code should be like that:

fd.spRendered(function () {

   //Employee Balances and name check

    compareNameToCurrentUser();
    
    fd.fied('PeoplePicker').$on('change', function(value) {
        getUserProvince(value.Key);
    });
});

Please also see Nikita's post on how to debug custom code: