How could one go about obtaining a reference to a newly created or imported sheet?
The method I tried was getting an array of all sheets in the active spreadsheet and iterating through those sheet objects to get the sheet with the highest ID number. I did this because the documentation for Sheet.getSheetId() notes that:
The ID is a monotonically increasing integer assigned at sheet creation time that is independent of sheet position.
and I took that to mean that the ID of every new sheet is always higher than the ID of any other existing sheet. But I quickly found out with a bit of experimenting that new sheets are not guaranteed to have the highest ID. In particular, I found that if you create a new sheet and rename it, then that new sheet does not always have the highest ID, but if you leave the name as is (i.e. "Sheet5", etc.), then the new sheet does have the highest ID.
I'm new to Google Apps scripting so I admit that this whole sheet ID business is confusing me. All I want is to be able to get a reference to the most newly created or imported sheet.