Is there and function availabel for which we can find the previous task id in an external task
OOTB there is no such function. You'd have to code it.If you have single possible Predecessor you can perhaps get a Task Object using WFworkflow::GetTaskByNameand then WFtask::GetId.For multiple Predecessors you can set up this information yourself in the predecessor task(s) so that required task can access it. Use "wfvarfinishop" attribute of the user/group tasks to set the callback value for the (following) external task.
Finally, you can get and parse Workflow objects, as raw XML or with (some) help from TeamSite::WFutils.Note that it's neither trivial nor documented/supported by IWOV.
The wfvarstartop and wfvarfinishop are, IMO, often overlooked but useful parts of the workflow design - you can easily use them to set the value of a variable (e.g.: "last_task") to the name of the current task using "%task" - and then, as indicated above - reference the same variable from the next task in line (assuming it is a script-oriented task type) to find out which task transitioned to it (using the information in the first previous paragraph above to get the ID of the task [if needed])