I am trying to generate a reference number every time a new data in inserted automatically from Google Form. I would like to generate the format as TMS180001 until the maximum possible reference number which is TMS189999. I could not figure how to format the value/string to 0001 instead of 1 and when I ran below code nothing happened.
function onFormSubmit(e) {
var Time = e.values [0]; //column 1 timestamp
var TMSrefnum = [10]; //column 1 till 9 are other information while
//column 10 is the reference number
if (Time = true); //if timestamp has value then add reference
//number to column 11
var i = 1 ; i < 9999 ; i++;
TMSrefnum = "TMS18" + toString(i);
}