I'm trying to understand the problem you are trying to solve.  And what is the wrong with the code you have?  It creates a new uuid as the discussion id if there is no discussion id?