Callback after upload or ...?

I created an uploadfield to upload related files. For now the field is merely meant to upload related files. The files are collected in another view so the field value isn’t that important. My initial idea was to empty the field after the file is uploaded (and/or moved) to the right folder.

I create a field
$crud->setFieldUpload(‘pdfnaam’, ‘library’, $libraryPath);
to upload the files. I want them however to go to a folder that’s numbered with the primary key.
i tried:
$stateInfo = $crud->getStateInfo();
$customerId = $stateInfo->primaryKeyValue;

$librarypath."/".$customerId in the setFieldUpload, but I get an error. Obviously because in it’s initial state there is not yet a primaryKeyValue.

I tried moving the file in a CallbackAfterUpdate, but I get an error that moving/renaming isn’t available.
I also tried filtering the state but I can’t find a way to pass the value of the pr.Key.Val to the upload path.

So basically the Upload should go to $base_Url . $librarypath . $primaryKeyValue instead of $base_Url . $librarypath

Is there anyone who has a solution?
Thank you