Hi @dennisp93 and @sergi0fores
If by adding the post id as the second parameter the method works, then the problem is related to the post id.
It is possible that the current post id does not reflect the posts that have the custom field.
You could try <?php $postid = get_the_ID(); echo $postid; ?>
to see the current loaded post id.