it seems we are changing from document.getCreationDate() to doc.getCreationDate() and there is no doc variable.
doc
Whoops, that's a typo.