Logo
For example "scheduled tasks"
Search
Info
Content
Category Navigation
  •   Snippets

  • Change the Time Field to a Dropdown

  • Trigger Refresh When Integromat Completes

  • Converting an Index Match Setup to Tadabase

  • Set Link Button to Open in a New Tab

  • How to Hide Component Based on “No Records” in Table

  • Change Link Button Color CSS for Active/Hover

  • JS to Show/Hide Components Depending on Multiple Data Fields

  • Google Charts Integration

  • Change the Background Color of 2 Cards if the Numbers Match

  • Save IP Address of Logged in User to the Record

  • Add Logged in User's IP Address to Form

  • Enlarge Thumbnail Images

  • Link Button Pop-up

  • Field Title Language - Based on Logged in Users' Language

  • Filter Tab - Background Color

  • IF 2 Card Component Value's Match - Change Background Colors to Match

  • Show Progress Based on Field Value

  • Export Multiple Tables in a Single File

  • Specify Size of Image Model Popup

  • Refresh Entire Page after Form is Submitted

  • Change Labels Language

  • Run Basic Math in Real Time on a Form

  • Set your Data Table to Auto-Refresh

  • CSS Color Gradient

  • Embed Your App in a Webpage Without iFrame or Embed Code

  • CSS for Table Component Title Text

  • Vertical Text in Columns and Fields

  • Mobile Menu Logo - When Menu is Closed

  • View Record Details on Parent Page

  • Show loading GIF while Action Links Run

  • Show columns based on the Users Role

  • Change Checkbox Size

  • Quick and Easy PDF Preview

  • Card Component - Display Sales - Today vs. Yesterday

  • A Multi-Company Project Management Tool

  • Multi-Item Select for Form Input

  • Set "Inputmode" on a Currency Field to a Decimal

  • Remove Link from Signature Fields in Details Components

  • Change Sub Menu Background Color and Text on Hover

  • Change Image Thumbnail Sizes

  • Change the Default Record Count Text

  • Copy Text on Click

  • Delete Connected Child Records Along with the Parent Record

  • Limit Text- Show more

  • Pause a Redirect of the Form

  • Display Addresses in a Single Line in Table Components

  • CSS Option for Connection Fields in a Form Component.

  • Generate Static Map Image

  • Delete Link on Child Page

  • Convert your Calendar's Language

  • Include “Add New” Text Button When Using "table-style-2"

  • Keep Columns Horizontally side by side on Mobile Devices

  • Using Javascript to Manipulate Records Without Tadabase REST API

  • Hide Columns Based on User Role

  • Add Speech Recognition to Your Form

  • Create an Anchor Link Button

  • Refresh all Tables When Form is Submitted

  • Customize Pagination Colors

  • Keep Active Menu Item Highlighted

  • Remove Background Color on Menu Item Hover and Focus

  • Hide Submit Button Unless all Radio Options are “Yes”

  • Set a date based on a Quarter and Year

  • Hover text - Buttons

  • How to use (space) delimiters in an input-field for numbers in text-field

  • Back Button

  • Customize the Form Submission Dialog Box.

  • Change Theme Button Colors

  • Fire Confetti🎉 When Submitting a Form

  • How to Add Checkboxes to Your Table and Add Logic to Them!

  • Photos in Gallery Display

  • Use Buttons to Search a Date Within a Range

  • Link highlighting Without Underline

  • Hide the Refresh Box and Records Display in a Table.

  • Move Form “Save” Button to Top of Form Page

  • Card Component Enhancement

  • Apply CSS class to PDF Print/Download Button

  • How to Hide Arrows from Input Number

  • Only Show Component if it’s the First Week of the Month

  • Hide Components when there are no Records

  • Multi-Step Background and Number/Icon Text Color

  • Use a Custom Icon in Card

  • Left Align Radio Buttons

  • Table Thumbnail Image Percentage Related Sizing

  • How to Round Filter Tabs

  • Table Style 2

  • Table Style 3

  • Table Style 4

  • Table Style 5

  • Details Style 1

  • Form Style One

  • Form Style 2

  • Form Style 3

  • Form Style Three

  • Form Style 4

  • Form Style 5

  • Animated Save Button - Grab Attention

  • Trigger Submit Button of the Other Form

  • Mask Sensitive Form Values

  • Capitalize First Letter in Fields

  • Change Header Size - Resource Component

  • Wrap Navigation Tabs for Mobile

  • Custom Print

  • Run JavaScript from an HTML Button Onclick Event

  • Record Validation for a Specific Word.

  • Remove "Years" from a Date Formatted as Age

  • Create a Record Entry Alternative to Using a QR Code Scan

  • JSChart Custom Component

  • Concatenate Multi-Select Connections

  • Add Freshdesk for Certain Roles or Pages

  • Hide Specific Part of a Menu Based on Logged in User Status/Role

  • Simple Scraper Setup

  • Validation rule - Validate against a connected field using a pipe

  • Change Button Based on Record Value

  • Hide Menu Links Based on Roles, Status or Logged in Users

  • How to add Delete Functionality Inside a Modal

  • Add a 360 tour to a Page.

  • Create X Amount of Connected Records Based on a Number Field

  • Pre Populate & Disable Date Range

  • Covert Action button to Text when Pushed

  • Access Data Table Records from JS

  • Concat Multiple Checkboxes While Filtering Duplicates

  • Read Receipts for When User Views the Details Page.

  • Number Count in Badge With Extra Filters

  • How to Customize the Language of your Tadabase Charts

  • Save records to Google in batches

  • Override Action Link with Confirmation Popup

  • How to Add Custom Themes to your Tadabase Charts

Categories
Snippets
Save records to Google...

Save records to Google in batches

 

/*************
* Variables
**************/
var Tadabase_App_Id = '<REPALCE WITH YOU APP ID>';
var Tadabase_Api_Key = '<REPLACE WITH YOUR API KEY>';
var Tadabase_Api_Secret = '<REPLACE WITH YOUR API SECRET>';

/*************
* API Settings
**************/
var Api_Url = 'https://api.tadabase.io/api/v1/data-tables';
var Table_Id = 'o6WQb5NnBZ';
var Request_Var = {
        'method' : 'GET',
        'headers': {
           "X-Tadabase-App-id" : Tadabase_App_Id,
           "X-Tadabase-App-Key" : Tadabase_Api_Key,
           "X-Tadabase-App-Secret" : Tadabase_Api_Secret
        }
    };


/*************
* Custom Menu
**************/
/* 
Function : onOpen
Descriptions : Add Custom Menu in Spreatsheet menus
Attach with menu : Clear Sheet
*/
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Records')
      .addItem('Get All Records', 'getAllRecords')
      .addItem('Clear Sheet', 'removeRecords')
      .addToUi();
}

/* 
Function : getAllRecords
Descriptions : Get All Records
Attach with menu : Get All Records
*/
function getAllRecords() {
  SpreadsheetApp.getUi();
  var r = Browser.msgBox('Confirmation', 'Are you sure want Get All Records ?', Browser.Buttons.YES_NO);
  
  if(r == 'yes'){
    getRecords();
  }
}

/* 
Function : removeRecords
Descriptions : Remove All Records
Attach with menu : Clear Sheet
*/
function removeRecords() {
  SpreadsheetApp.getUi();
  var r = Browser.msgBox('Confirmation', 'Are you sure want Delete All Records ?', Browser.Buttons.YES_NO);
  if(r == 'yes'){
    var Spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
    var Sheet = Spreadsheet.getActiveSheet();
    Sheet.clear();
  }
  
}
/*End Custom Menu*/

/* 
Function : getData
Descriptions : get API records
*/
function getData(limit, page) { 
  var response = UrlFetchApp.fetch(Api_Url+"/"+Table_Id+"/records?limit="+limit+"&page="+page, Request_Var);
  return JSON.parse(response);
}

/* 
Function : getRecords
Descriptions : Get All Records and show on sheet
*/
function getRecords() {
  var Spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var Sheet = Spreadsheet.getActiveSheet();
  var response = UrlFetchApp.fetch(Api_Url+"/"+Table_Id+"/fields", Request_Var);
  var cols = JSON.parse(response);
  
  var records = new Array();

  // Set Header
  var header = cols.fields.map(function(f){ return f.name } );
  Sheet.appendRow(header);
  var total_header = header.length;
  var header_row = Sheet.getLastRow();

  var allitems = new Array(); 
  var page = 1, limit = 1000, $flag = true;

  while ($flag) {
      var response = getData(limit, page);
      if (response.hasOwnProperty("type") && response.hasOwnProperty("items") && response.type=='success') {
          for (var i in response.items) {
              record = new Array();
              var item = response.items[i];
              for (var iv in cols.fields) {
                  var field = cols.fields[iv];
                  if (typeof item[field.slug] !== 'undefined') {
                      var arr = new Array();
                      var values = item[field.slug];
                      switch (field.type) {
                          case 'Name':

                              var field_index = header.indexOf(field.name);
                              if (values.hasOwnProperty('title')) {
                                  record.push(values['title']);
                                  if (header.indexOf(field.name + " > Title") < 0) {
                                      header.splice(field_index, 0, field.name + " > Title");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('first_name')) {
                                  record.push(values['first_name']);
                                  if (header.indexOf(field.name + " > First Name") < 0) {
                                      header.splice(field_index, 0, field.name + " > First Name");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('middle_name')) {
                                  record.push(values['middle_name']);
                                  if (header.indexOf(field.name + " > Middel Name") < 0) {
                                      header.splice(field_index, 0, field.name + " > Middel Name");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('last_name')) {
                                  record.push(values['last_name']);
                                  if (header.indexOf(field.name + " > Last Name") < 0) {
                                      header.splice(field_index, 0, field.name + " > Last Name");
                                      field_index++;
                                  }
                              }
                              //Remove Name Field from header
                              if (header.indexOf(field.name) > 0) {
                                  header.splice(header.indexOf(field.name), 1);
                              }
                              break;

                          case 'Date Range':

                              var field_index = header.indexOf(field.name);
                              if (values.hasOwnProperty('start')) {
                                  record.push(values['start']);
                                  if (header.indexOf(field.name + " > Start Date") < 0) {
                                      header.splice(field_index, 0, field.name + " > Start Date");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('end')) {
                                  record.push(values['end']);
                                  if (header.indexOf(field.name + " > End Date") < 0) {
                                      header.splice(field_index, 0, field.name + " > End Date");
                                      field_index++;
                                  }
                              }
                              //Remove Date Range Field from header
                              if (header.indexOf(field.name) > 0) {
                                  header.splice(header.indexOf(field.name), 1);
                              }

                              break;

                          case 'Link':

                              record.push(values['link']);
                              break;

                          case 'Checkbox':
                          case 'Multi-Select':

                              if (Array.isArray(values)) {
                                  record.push(values.sort().join(','));
                              } else {
                                  record.push('');
                              }
                              break;

                          case 'Address':

                              var field_index = header.indexOf(field.name);
                              if (values.hasOwnProperty('address')) {
                                  record.push(values['address']);
                                  if (header.indexOf(field.name + " > Address") < 0) {
                                      header.splice(field_index, 0, field.name + " > Address");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('address2')) {
                                  record.push(values['address2']);
                                  if (header.indexOf(field.name + " > Address 2") < 0) {
                                      header.splice(field_index, 0, field.name + " > Address 2");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('city')) {
                                  record.push(values['city']);
                                  if (header.indexOf(field.name + " > City") < 0) {
                                      header.splice(field_index, 0, field.name + " > City");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('state')) {
                                  record.push(values['state']);
                                  if (header.indexOf(field.name + " > State") < 0) {
                                      header.splice(field_index, 0, field.name + " > State");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('country')) {
                                  record.push(values['country']);
                                  if (header.indexOf(field.name + " > Country") < 0) {
                                      header.splice(field_index, 0, field.name + " > Country");
                                      field_index++;
                                  }
                              }
                              if (values.hasOwnProperty('zip')) {
                                  record.push(values['zip']);
                                  if (header.indexOf(field.name + " > Zip") < 0) {
                                      header.splice(field_index, 0, field.name + " > Zip");
                                      field_index++;
                                  }
                              }

                              //Remove Address Field from header
                              if (header.indexOf(field.name) > 0) {
                                  header.splice(header.indexOf(field.name), 1);
                              }
                              break;

                          case 'File':

                              if (typeof values === 'object' && (values != [] && values != null) && Object.keys(values).length) {
                                  record.push(values['url']);
                              } else {
                                  record.push('');
                              }
                              break;

                          case 'Image':

                              if (typeof values === 'object' && (values != [] && values != null) && Object.keys(values).length) {
                                  record.push(values['src']);
                              } else {
                                  record.push('');
                              }
                              break;

                          case 'Connection':
                          case 'Join':

                              if (typeof values === 'object' && (values != [] && values != null) && Object.keys(values).length) {
                                  var connectionSlug = field['slug'];
                                  var connectionSlugValue = connectionSlug + '_val';
                                  var connectionValue = item[connectionSlugValue];
                                  var vals = Object.keys(values).map(function(key) {
                                      return values[key];
                                  });
                                  if (field.type == 'Join' && connectionValue.length) {
                                      record.push(connectionValue[0].val);
                                  } else {
                                      record.push(vals.join(' '));
                                  }
                              } else {
                                  record.push('');
                              }
                              break;

                          default:

                              if (typeof values === 'object' && (values != [] && values != null) && Object.keys(values).length) {
                                  var vals = Object.keys(values).map(function(key) {
                                      return values[key];
                                  });
                                  record.push(vals.join(' '));
                              } else {
                                  record.push(item[field.slug]);
                              }
                              break;
                      }


                  }
              }

              //Refresh Header if change
              if(header.length != total_header){
                Sheet.getRange(header_row, 1, 1, header.length).setValues([header]);
              }

              Sheet.appendRow(record);
          }
      }

      if (!response.hasOwnProperty("total_pages") || page >= response.total_pages) {
          $flag = false;
      } else {
          page += 1;
      }
  }
}

 

How did we do ?

Previous Article
How to Customize the Language of your Tadabase Charts
Next Article
Override Action Link with Confirmation Popup
Back to top
API
100% Operational
Apps
100% Operational
Builder
100% Operational
Overall Status
100% Operational