Logo
For example "scheduled tasks"
Search
Info
Content
Category Navigation
  • ๐Ÿ“–  Manual

  • ๐Ÿ‘‹Welcome

    Welcome to Tadabase

    What Is No-Code?

    Tadabase Support

    Getting Started With Tadabase

    Platform Overview

    ๐ŸงฐThe Data Builder

    Data Tables

    Fields

    Text Fields

    Personal Fields

    Number Fields

    Date Fields

    Option Fields

    File and Image Fields

    Equation Fields (Category)

    Equation Fields

    Connection Fields

    Date Equation Examples

    Records

    Record Logs

    Import Templates

    Export Templates

    Automating Tasks

    Number Equation Examples

    Text Equation Examples

    Multi-Function Equation Examples

    โœ๏ธPage Builder

    Page Builder Overview

    Layouts

    Pages

    Components Overview

    PDF Pages

    ๐Ÿ“—System Components

    System Components Overview

    Menu

    User Menu

    Breadcrumbs

    PDF Print (Alpha)

    Link Button

    Login

    Signup

    Profile

    HTML

    Image

    Subscriptions (Alpha)

    ๐Ÿ“˜Data Components

    Data Components Overview

    Form Component

    Table Component

    List Component

    Kanban Component

    Calendar Component

    Resource Component

    Map Component

    Timeline Component

    Accordion Component

    Card Component

    Chart Component

    Search Component

    Import Component

    Data Source

    Data Source Filtering

    Links

    Display Rules

    Inline Editing

    Data Component Visual Directory

    Custom Component

    Custom Component Helpers

    Writing Your Own Component Helpers

    ๐Ÿ™‹Users

    Users

    Roles

    Single Sign On (SSO)

    Adding Stripe Subscriptions

    ๐Ÿ”’Security and Reliability

    Tadabase Builder Security

    App Security

    User Security

    ๐Ÿ”—Integrations

    Zapier Integration

    Using Webhooks

    Saving files to Dropbox

    Adding PayPal payment buttons to your app

    Exporting records to Google Sheets

    Viewing data in Microsoft BI

    Chat Widgets

    REST API

    Using SendGrid for emails

    Saving files to AWS S3 Bucket (IAM Method)

    Incoming Webhooks

    Embeddable Components

    Saving Files to Custom S3 Bucket (Account Method, Recommended)

    PDF Forms

    Stripe Checkout

    JavaScript Callbacks and Actions

    Twilio Integration

    โš™App Settings

    General Settings

    Layout & Format Settings

    Custom Domain

    Customizing CSS

    Changing app themes

    Support Settings

    404 Error Page

    ๐Ÿ’ณAccount

    Plans

    Managing Your Account

    Sharing your app builder

    Managing your Apps

    ๐ŸงฉPipes

    Introduction to Pipes

    Adding Pipes

    Using Pipes

    PDF Gen V2

Categories
๐Ÿ“– Manual
๐Ÿ”— Integrations
Exporting records to G...

Exporting records to Google Sheets

In this article we will discuss how you can export records from your Tadabase app to Google Sheets.ย 

If you would like to back up your data tables in your Tadabase app to Google Sheets, you can export your records via Tadabase's Zapier or Integromat integrations or by using Google Scripts.ย 

In this article we will demonstrate how to export records from a data table in your Tadabase app to Google Sheets using Google Scripts.ย 

At this time, Tadabase does not support native integration with Google Sheets. However, due to popular request from our customers we have provided a Google Script for you to utilize to export your records from your Tadabase app to Google Sheets. Please keep in mind that as Tadabase does not natively integrate with Google Sheets we can not support issues or further customization needs with your export. While we provide this article as a courtesy to our valuable customers, please keep in mind that we can not support any issues you may experience with your export.

ย 

To begin your export, open a new Google Sheet and selectย Extensions > Apps Script:

2022-04-05_12-25-20.png

ย 

Next, delete everything in the new script window and copy/paste the script below into the editor.ย 

/*************
* 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 = '<REPLACE WITH YOUR TABLE ID>';
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', 'getall_records')
      .addItem('Clear Sheet', 'remove_records')
      .addToUi();
}

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

/* 
Function : remove_records
Descriptions : Remove All Records
Attach with menu : Clear Sheet
*/
function remove_records() {
  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 : get_data
Descriptions : get API records
*/
function get_data(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();
  var header = new Array();
 
  for ( var i in cols.fields) {
    var d = cols.fields[i];
    header.push(d.name);
  }
  
  var allitems = new Array(); 
  var page = 1, limit = 100;
  var rec = get_data(limit,page);
  allitems = rec.items;
  if(rec.total_pages > 1) {
    for (var i = 2; i <= rec.total_pages; i++) { 
      var rec = get_data(limit, i);
      for ( var r in rec.items) {
        allitems.push(rec.items[r]);
      }
    }
  }
  
  for ( var i in allitems) {
    records[i] = new Array();
    var item = allitems[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') ) {
                      records[i].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') ) {
                      records[i].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') ) {
                      records[i].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') ) {
                      records[i].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') ) {
                      records[i].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') ) {
                      records[i].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' :
               
                    records[i].push(values['link']);
                    break;
                       
               case 'Checkbox' :
               case 'Multi-Select' :

                    if(Array.isArray(values)) {
                       records[i].push(values.sort().join(','));
                    } else{
                      records[i].push('');
                    }
                    break;

              case 'Address' :
                     
                     var field_index = header.indexOf(field.name);
                     if( values.hasOwnProperty('address') ) {
                       records[i].push(values['address']);
                       if( header.indexOf(field.name+" > Address") < 0 ) {
                         header.splice(field_index, 0, field.name+" > Address");
                         field_index++;
                       }   
                     }
                     if( values.hasOwnProperty('address2') ) {
                       records[i].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') ) {
                       records[i].push(values['city']);
                       if( header.indexOf(field.name+" > City") < 0 ) {
                         header.splice(field_index, 0, field.name+" > City");
                         field_index++;
                       }
                     }
                     if( values.hasOwnProperty('state') ) {
                       records[i].push(values['state']);
                       if( header.indexOf(field.name+" > State") < 0 ) {
                         header.splice(field_index, 0, field.name+" > State");
                         field_index++;
                       }
                     }
                     if( values.hasOwnProperty('country') ) {
                       records[i].push(values['country']);
                       if( header.indexOf(field.name+" > Country") < 0 ) {
                         header.splice(field_index, 0, field.name+" > Country");
                         field_index++;
                       }
                     }
                     if( values.hasOwnProperty('zip') ) {
                       records[i].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 ){                       
                        records[i].push( values['url'] );
                      } else {
                        records[i].push('');
                      }
                      break;
               
              case 'Image' :
               
                     if( typeof values === 'object' && (values != [] && values != null) && Object.keys(values).length ){                       
                        records[i].push( values['src'] );
                      } else {
                        records[i].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'){
                         records[i].push( connectionValue[0].val );
                       } else {
                         records[i].push( vals.join(' ') );
                       }
                     } else {
                        records[i].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];
                         });
                       records[i].push( vals.join(' ') );
                     } else {
                        records[i].push(item[field.slug]);
                     }
                     break;
          }
       }
    }
  }
  
  // Set Header
  Sheet.appendRow(header);
  
 // Records  
  for ( var i in records) {
    Sheet.appendRow(records[i]);
  }

}

ย 

Be sure to replace the App ID, API Key, API Secret, and Table ID with the credentials from your app:

TD88sKgLh48u8S1xueMEefVtBgeDhaiCTw.png

ย 

You can retrieve the API credentials from your app settings by clicking Settings on your app's navigation bar and selecting API Keys:

R068ehC0OoEnKCQDjGcoA87Kck-XJHf9jw.png

ย 

The Table ID can be located by clicking on your selected data table in the Data Builder and retrieving the values from within the URL of the page:

X6ax0rAAdvEDI2jAkmXjbY88_j-b7NBtqA.png

ย 

Once you have updated the credentials in your app, click Save in the script window.ย 

Back in the Google Sheet window, refresh the page and wait about 3-5 seconds. You will see a new menu tab appear called "Records" which you can click on and then select Get All Records:

T6stXcLM5EWExNqbHAGBZqgz5FYvj7qLTA.png

ย 

Click Continue to authorize the script:

hv32D2f0phk_zjLBUYsUMw0XgyyESJIZwA.png

ย 

Next, click Allow to grant Google Scripts the access to perform this API request:

2T8iQ0DlbXBA5yYXvw3jg7c2gQNbxn4Piw.png

ย 

Finally, click Yes to confirm that you would like to pull all the records from your selected data table:

czXfutVwmMuj1SJ_j2lkaDFKbSpdwsKzFQ.png

ย 

Within the next few seconds you will begin to see all of your data table records appear in the sheet:

XfZOpqMFdpkPTadOUPYdOoEyxAinNl0JQw.png

ย 

Congratulations, you have successfully exported your data table records from Tadabase to your Google Sheet.

How did we do ?

Previous Article
Adding PayPal payment buttons to your app
Next Article
Viewing data in Microsoft BI
Back to top
Developer portal Tadabase Community
API
100% Operational
Apps
100% Operational
Builder
100% Operational
Overall Status
100% Operational