How to get latest entry created in doctype..in custom script

Well, you can retrieve a doctype modification date with: cur_frm.doc.creation
Then, you can filter the result to only get the latest date with python (python - Find oldest/youngest datetime object in a list - Stack Overflow)
or with frappe filters like this one:
Frappe Api issue in filtering between two dates - #2 by aldoblack