That part of the process is both the easiest, and the trickiest. All you have to do is fail a ruler election, and you're there. But this process also allows someone in the realm a chance to sabotage the process, if they desire, and get elected.
Is it still possible to make it dukes vote only, after the code change? Or only dukes eligible for the post? That might simplify matters.