Logo
For example "scheduled tasks"
Search
Info
Content
Category Navigation
  • 🎯  Solution Guides

  • Low Code Solutions

    Add "Tabs" to your app

    ID Target Link

    Use an address field to display a static street view thumbnail

    Turn your menu into a fixed menu

    Auto close mobile menu

    Display record information in a card

    How to add a back button to your app

    Add a collapsible accordion element to your app

    Code Snippets

    PHP Curl Create New Record

    PHP Get Records With Filters

    Google Scripts - Get record and create new records from connected table

    Save Tables and Fields into Spreadsheet

    Google Scripts - Export all records

    Webhook to save deleted records

    Send Messages to Slack

    Restrict Space and Force Uppercase in a Form

    Building Advanced Features

    Use Validation Rules to Ensure Unique Votes Per User

    Use Record Rules to Create an Audit Log

    Track current inventory with transactions

    Schedule Bookings and Prevent Double Bookings

    Create orders with multiple items and varying quantities

    2 Step Forms

    Unique Record Validation

    Restrict Editing Records to Record Owners

    Sum date/time field

    Duplicate Records

    Advanced App Customization

    How to embed a Tadabase page on another website

    Adding external fonts

    Custom Favicon

    Making apps mobile friendly

    Show date/time as a countdown

    Importing many images at once

    Adding QR Codes

    Adding charts to PDFs

    Customizing your app shortcut for mobile phones

    Animate parts of a page

    Design Customization

    Changing background colors

    Set background colors to the edge of a page

    Change the background of a column

    Add padding around a component

    Using an image as background for a page

    Adding a background image to a row, column, or component

  • Duplicate Connected Records

Categories
🎯 Solution Guides
Code Snippets
Save Tables and Fields...

Save Tables and Fields into Spreadsheet

Export all Fields and Tables

When you're working with API you'll often need to reference tables and all the field slugs in each table. You can use this little script to export all of these into a spreadsheet. 

get-fields-optimized.gif

 

Create a new Google Sheet and go to the App Scripts: 


Paste the following code and make sure to update the first 3 lines with your API details: 

/*************
* Variables
**************/
var Tadabase_App_Id = 'APPID';
var Tadabase_Api_Key = 'APIKEY';
var Tadabase_Api_Secret = 'APISECRET';

/*************
* API Settings
**************/
var Api_Url = 'https://api.tadabase.io/api/v1/data-tables';
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
*/
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Tadabase')
      .addItem('Get Tables and Fields', 'saveMenu')
      .addToUi();
}

function saveMenu() {
  SpreadsheetApp.getUi();
  var r = Browser.msgBox('Confirmation', 'Are you sure want Save Table Fields ?', Browser.Buttons.YES_NO);
  
  if(r == 'yes'){
    save();
  }
}


/* 
Function : getFields
Descriptions : Get All the Fields For Each Table
*/
function getFields(table_id) {
  var response = UrlFetchApp.fetch(Api_Url+"/"+table_id+"/full-fields-info", Request_Var);
  return JSON.parse(response);
}

/* 
Function : getFields
Descriptions : Get API DataTable
*/
function getDatatables() {
  var response = UrlFetchApp.fetch(Api_Url + "/", Request_Var);
  response = JSON.parse(response);
  if(response.type == "error"){
     SpreadsheetApp.getUi().alert(response.msg);
     return false;
  }
  return response.data_tables;
}

/* 
Function : Save
Descriptions : Save API Table Fields
*/
function save() {
  
  var data_tables = getDatatables();
  var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var Sheet = activeSpreadsheet.getActiveSheet();
  
  Sheet.appendRow(['Field Name', 'Type', 'Slug', 'Table Name', 'Table ID']);
  for ( var i in data_tables) {
    
    var table = data_tables [ i ];
    var getfields = getFields(table.id);
    
    if(getfields.type == "success"){
      
      for ( var j in getfields.fields) {
      
         var field = getfields.fields[j];
        
         Sheet.appendRow([field.name, field.type, field.slug, table.name, table.id]);
    
      } // End for
  
    } // End if
  
  } // End for
  
}

Press Save, or Ctrl + s. 

Go back to your spreadsheet and refresh the page. After several seconds you will see a new menu option called "Tadabase" 

Press "Get Tables and Fields"

After confirming the selection  you will see all your tables and fields displayed on the page: 

How did we do ?

Previous Article
Google Scripts - Get record and create new records from connected table
Next Article
Google Scripts - Export all records
Article Navigation
  • Export all Fields and Tables
  • Back to top
    API
    100% Operational
    Apps
    100% Operational
    Builder
    100% Operational
    Overall Status
    100% Operational