How to handle entry save in plugin when entryId is not set?
Had to browse through your plugin repo for a bit to try and wrap my head around what's going on, but I think you have the problem nailed down in that the issue is this: https://github.com/iNalgiev/webtexttool1/blob/1.0.0/WebtexttoolPlugin.php#L57

Trying to grab the entry ID from the cp.entries.edit.right-pane template hook for a new entry is going to return null because IDs aren't assigned until after the element is saved.

Off the top of my head, you've got two not-so-thought-out options.


Refactor your plugin logic so that the code that eventually calls your controller/service's saveRecord methods happen after the entry has been saved in onSaveEntry and you've got a valid entry ID.
Come up with some AJAXy way to calling Craft's saveEntry method from the cp.entries.edit.right-pane template hook that returns the entry ID so the rest of your logic can assume that the entry already exists.