correct, has to be run within the deployed script file to work. Interesting that you got it to work on the RP. FYI this is the piece of code I am running, is yours any different?
var context = nlapiGetContext():
console.log(context.getDeploymentId());