You would need a megally big slowcooker to cook for 40 people. I have done mash potatoes in the slowcooker many times. But for 40 people I would recommend a roaster.
Peel and chop your potatoes place them in a roaster or slocooker and cover with water. Cook on high for 4 or more hours. Rule of thumb more the potatoes the longer you are going to need to cook them. Little chunks of potatoes help cook faster. Drain all the liguid. Start mashing up the potatoes. Then add the butter, seasonings and milk. A little milk first. Then add more as you mix them up to make mash potatoes. Mash right before your ready to serve. If your needing to do it earlier then planned. Watch you don't scortch the sides of the mashed potatoes in the roaster or slowcooker.
I love making mash potatoes in the slowcooker. Especially I will peel the potatoes and place them in waer in the slowcooker before church. Have them cooking and come home from church, drain and have mash potatoes to go with the meat dish I placed in another slow cooker.
I have also used roasters to cook for crowds of people for a holiday dinner.