Search code examples
google-apps-scriptgoogle-sheetside

How to assign Execution Type to Apps Script functions


I have to daily check the execution log of my Apps Script Addon. I have a lot of executions of the onOpen() function (always a user opens a sheet document in my office), and I want to hide these executions. I tried filtering execution Type and checking all the options except Simple Triggers, but then I can't see the rest of functions triggered by users, because the Type of my addon functions are set as "Unknown" (and unknown is not in the filter list). It's possible to assign a type of the list to the addon functions, or hide the Simple Triggers in another way?

Thanks!


Solution

  • I don't think it's possible to set a execution type. However, You can use the url to filter by execution type. The format is:

    https://script.google.com/home/projects/{PROJECT_ID}/executions?type={TYPE_ID}[.{TYPE_ID}]
    

    where

    • PROJECT_ID is the id of the project. Eg: t1cjovovstuxihcohciyc1h_66hg
    • TYPE_ID is the id of the execution type. Eg: 1 for ADD_ON, 7 for WEB_APP

    For eg, To filter in executions of type Addon OR Webapp, use

    https://script.google.com/home/projects/t1cjovovstuxihcohciyc1h_66hg/executions?type=1.7
    

    To filter in "Unknown" type executions, use type id 0

    https://script.google.com/home/projects/t1cjovovstuxihcohciyc1h_66hg/executions?type=0
    

    You can also directly use the Google cloud stackdriver logging, which offers much more filtering features, provided you change your GCP to standard.