$contactId = CRM_Utils_Request::retrieve('cid', 'Positive');
$contactId = (int) $_GET['cid'];
$contactId = $form->getVar('_contactID');
Are all possible solutions at different places, but none seem to work when in a Form_CustomData.
In this case the cust data is in an Activity for a civiCase
For the avoidance of doubt, this is to get the ID for the contact (not the user)
Edit: additional info.