Why would you do this in Java script, and not in, e.g., an OnChange miroflow, or when opening the screen?
Rom van Arendonk
This is just a guess, but here goes:
I think you need to to use the ID of the referencing object. You can't use a normal String value which you create yourself.
The reference selector is a reference to another entity, so you need to map it to a Database Object, and use the ID of the correct database record.
How and IF this is even possible, I have no idea. I agree with Rom in that you should use the platform itself to handle things like this