Summary: Do you have many Toggl workspaces and want to add the same projects to all? We created a Google spreadsheet file in which you can list all you projects. Once you click the button, all project names are automatically added to your listed workspaces.

In order to have good performance in each of your projects, it will be so helpful to track the time you spend to finish them. The lower time you assign to projects, the more projects you can manage. So we need a software to do us this favor. Toggl is a time tracking software that allows you to track your activities. Time tracking software such as Toggl is widely used by many companies mainly because it provides detailed insight into company’s or project’s status. It is awesome since you can integrate Excel Spreadsheet in google platform to toggle. This integration makes work easier, faster, and more convenient.

Integrations with google spreadsheets are so helpful especially in project management. Using the script we have written, projects managers can add projects to many workspace and assign them to different employees just by one click. The only thing you need to do this is using your API token (you can find it in your toggl profile) and workspaces ID. In the sample file we have prepared, there are 2 worksheets. First of all you should put your API token in Config sheet.

you can put your workspace ID in first column and your projects names to fourth row in “psheet”. Then to add a project to a workspace, simply check mark their intersection. Finally click on Send Projects to Toggl button.

This workbook has a script function “sendDataToToggl()” that handle this integration.

function sendDataToToggl()
{
  //counter will be used for counting added projects.
  var counter=0;
  //define variables for worksheets and necessary data
  var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
  var sht_config = 'Config';
  var sht_psheet = 'psheet';
  var configsheet = spreadSheet.getSheetByName(sht_config);
  var psheet = spreadSheet.getSheetByName(sht_psheet);
  var cfgdata = configsheet.getDataRange().getValues();
  var psheetdata = psheet.getDataRange().getValues();
  var apiToken = cfgdata[1][1];
  var unamepass = apiToken + ":api_token";
  var digest = Utilities.base64Encode(unamepass);
  var lastWorkSpace = psheet.getLastRow();
  var lastProject = psheet.getLastColumn();
  //connect to toggl api and send projects
  var digestfull = "Basic " + digest;
  var url = "https://www.toggl.com/api/v8/projects";
  for (i = 1; i < lastWorkSpace; i++)
     {
        var wid = psheetdata[i][0];
        for (j=2; j < lastProject; j++)
            {
              var pname = psheetdata[3][j];
              var data = {"project":{"name":pname,"wid":wid,"template_id":1793088}};
              var options = {
                              "contentType": "application/json",
                              "method": "post",
                              "headers": {"Authorization": digestfull},
                              "payload": JSON.stringify(data)
                            };
              if(psheetdata[i][j]==true)
                {
                  try { var response = UrlFetchApp.fetch(url, options);counter=counter+1} catch (e) {}
                }
            }
     }
  Browser.msgBox(counter+"  New projects successfully added")
}

By this instruction, managing your projects become easier than before. The best point of it is to save your time while managing a project, since you will be able to use your spreadsheets directly into the Toggl software.

To use this solution, open this Google Sheet and make a copy in your Google Drive account.

  • To figure out your workspace_id: go to Team in toggl.com. The number at the end of the URL is the workspace id.
  • To figure out your api_token: go to your Profile in toggl.com, your API token is at the bottom of the page.

 

Leave a Reply

Your email address will not be published. Required fields are marked *