Javascript to retrieve ID for current record and display in message box

Sometimes you need to know the ID of the record you are on (the ID isn't displayed on the form in CRM).

CODE:

function GetID ()

{

var myid = Xrm.Page.data.entity.getId();

alert('my id is' + myid );

}