$formValues field names
Without knowing on what form you are exactly, there is bound to be something like contributionId or contributionID in your form. 

You can find the name in the $form object (try debugging the object for the specific name) and then use $contributionId = $form-&gt;getVar('_contributionID') to get the field and use it in your hook (assuming you are using a hook).