When the sleepwalker urinates during a sleepwalking episode, he/she usually thinks they are in the bathroom, and therefore urinate where they think the toilet should be.
Sleepwalkers arise from the slow wave sleep stage in a state of low consciousness and perform activities that are usually performed during a state of full consciousness.