How can I get entry id in field
It may depend on where in the request you need to access the element.

If you need to access the element in a Field class on your Entry Edit page, the getInputHtml method may be useful:

public function getInputHtml($value, ElementInterface $element = null): string
{
    // $element stuff

    return Craft::$app-&gt;getView()-&gt;renderTemplate('my-plugin/field',
    [
        'field' =&gt; $this,

        // make the Element available in your field's input template
        'element' =&gt; $element
    ]);
}


If you need to access the element in a Field class after the Element is saved there is the afterSaveElement method:

public function afterElementSave(ElementInterface $element, bool $isNew)
{
    parent::afterElementSave($element, $isNew);

    // $element stuff
}


Note: The Entry ID may not exist while a new entry is being created. Accessing the Element via the afterElementSave ensures that the Entry has been saved and has an ID.