getThingStatusInfo error in OH3 script

Why am I getting the following error when trying to run a script to get the status of a thing in Openhab 3?

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘f362a052bb’ failed: ReferenceError: “getThingStatusInfo” is not defined in at line number 1

The rule is an example right out the OH Documentation site:

var thingStatusInfo = getThingStatusInfo("mqtt:topic:TasmotaColdStorage")

if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) {
    logInfo("ThingStatus", "The thing is online.")
} else {
    logError("ThingStatus", "The thing is offline or doesn't exist.")
}

You trying to run a rule as a script.
Run as rule

configuration:
  type: application/vnd.openhab.dsl.rule

Not

configuration:
  type: application/javascript

Thank you for the quick response. That was it for sure.

Example of working status report here.

Does it mean that one cannot use getThingStatusInfo() in a script?

I do not see any mention of this in the documentation - it is listed under actions and the top of the page says “Actions are predefined methods that are called from openHAB rules and scripts.

(I came here because I also tried to use the function in a script.)

This code works in a script:

var logger = Java.type("org.slf4j.LoggerFactory").getLogger("org.openhab.model.script.Rules.Experiments");

var ThingAction = Java.type('org.openhab.core.model.script.actions.Things')
var mowerThing = "automower:automower:iUID*********************************************************";

// Check if automower is ONLINE
var thingStatusInfo = ThingAction.getThingStatusInfo(mowerThing);
//logger.info("Debug1: {}", thingStatusInfo.getStatus());
//logger.info("Debug2: {}", thingStatusInfo.toString());
//logger.info("Debug3: {}", thingStatusInfo.getStatusDetail());
//logger.info("Debug4: {}", thingStatusInfo.getStatus().toString());

if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) {
  logger.info("ThingStatus: {}", "The thing is online.")
  
  var mowerState = Java.type('org.openhab.core.library.items.StringItem');
  mowerState = items.getItem("Husqvarna_Automower_405X_State");
  logger.info("Autower is {}", mowerState.toString());
  
  var automowerAction = actions.get("automower",mowerThing);
  automowerAction.parkUntilFurtherNotice();
  //automowerAction.resumeSchedule();
  
} else {
    logger.info("ThingStatus: {}", "The thing is offline or doesn't exist.")
}