Is there a way to get an NPC's RefID in game?

Solution 1:

You can either get their RefID by clicking on them with the console open to target them, which should display their RefID at the top of the screen (source: UESPWiki), or by looking at an exhaustive list like this one (also UESPWiki).

I haven't heard of any other ways but will update my answer if I find anything.

Solution 2:

If you can't see or click the NPC you want to get the RefID but you know its name, then on the console type "save funclist 1". It will open a txt file with every refID in your save game, just search for its name.