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:
$variable={document_id};

But I keep getting a pop up message:
Undefined Property:
form_formname_ini$document_id

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

Hello,

In which event are you running this code block?

regards,
Bernhard Bernsmann