Hi Blai,
You were too close to solve it, you only need to check the status of that field :
if(!$w("#dynamicDataset").getCurrentItem().fieldName){ // i used (!) to check if its empty
$w("#textField").collapse();
}
For more information about getting the current item - Check this
Good Luck.
Mustafa