Google Apps Script on Form Submit Time Formatting Glitch/Fix

前端 未结 2 960
无人共我
无人共我 2021-01-16 12:03

Background:

How: I suspect that this is a glitch within Google Form (submission process)/Spreadsheet, but may be part of the Date conversio

2条回答
  •  轮回少年
    2021-01-16 12:29

    If you remove the ' in the spreadsheet cell the spreadsheet interface will convert this entry to a date object.

    This might (or not) be an issue for you so maybe you should handle this when you read back your data for another use... It doesn't happen when text is different (for example with P.M) simply because in this case the ' is not necessary for the spreadsheet to keep it as a string since the spreadsheet can't convert it to a date object (time value).

    Artificial intelligence has its bad sides ;-)


    edit : You cant do this in an onFormSubmit triggered function using the javascript substring() you mentioned. If you're not familiar with that, here is the way to go :

    To run a script when a particular action is performed:

    1. Open or a create a new Spreadsheet.
    2. Click the Unsaved Spreadsheet dialog box and change the name.
    3. Choose Tools > Script Editor and write the function you want to run.
    4. Choose Resources > Current project's triggers. You see a panel with the message No triggers set up. Click here to add one now.
    5. Click the link.
    6. Under Run, select the function you want executed by the trigger.
    7. Under Events, select From Spreadsheet.
    8. From the next drop-down list, select On open, On edit, or On form submit.
    9. Click Save.

    see doc here and here

提交回复
热议问题