Field value is rendered during onCustomFieldsPrepareField
event which takes 3 arguments: the context string, content item object and the field object. The content item is the second argument passed to the event. If your plugin extends Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin
class, it should have this function signature:
public function onCustomFieldsPrepareField($context, $item, $field)
In that case the content item is $item
. You can access it inside the field layout. Just be aware that custom field plugins are normally designed to work with multiple content types which may not have the same properties as articles. If the logic in your plugin is specific to content articles, you should perform a context check to ensure the logic only runs when articles are concerned:
if ($context === 'com_content.article')
{
// Your code here
$articleId = $item->id;
}