Getting current document ID

I’m trying to load a document, get its current ID, and save it as a variable.
I’ve got a PHP method that I’m doing this in, so I can make a simple query off the document_id.
This simple query determines what the status should be.

It seems simple enough:

But I keep getting a pop up message:
Undefined Property:

$variable works, but I keep getting the pop up error message.


In which event are you running this code block?

Bernhard Bernsmann