Thanks.
I'm aware of that. But I assume getting a variable works differently in a plug-in.
I actually followed the example given in @peternlewis's reply to your post years ago.
This is the only resource I could find on the internet about using JXA for KM plug-ins.