Scripting Extensions

Scripting Extensions allows you to create custom functions and methods for JavaScript/TypeScript in Tabidoo.

Intro

Tabidoo includes a lot of features that make scripting easier. 
For example, to retrieve data, just call a generic function

const data = await doo.table.getData<IDooApiTableANY>('My table')

This built-in functionality makes coding very easy.

Scripting Extensions takes the possibilities even further. It allows you to write custom functions that can be reused anywhere in Tabidoo. In Workflow Automation, Free Html, etc. No more copy blocks are needed.

Install

Download the extension "Scripting Extensions" into your application. That's it.

Usage

The "Custom scripts" table is the place, where you can extend the Tabidoo standard scripting support.

The input screen contains this fields:

  • Name - just name the record
  • Order - in case you need to setup order, you can use that. Leave empty if not the case.
  • Property name - the name of the property/namespace, which will be appended after standard doo keyword. (doo.myFunctions.getNewGuid())
  • Interface - name of the interface for this property
  • d.ts - Interface(s) definition
  • Script - TypeScript to define the object. Properties and functions.

The best way would be to go through examples.

Examples


Example 1

We want to define a function, which takes two dates and return a nice text like 1/1/2013 - 2/1/2015

The call supposed to look like

doo.myFormatting.getTitle2Days(dateFrom, dateTo, 'en')

And the definition:

Name My formatting example

Property name myFormatting

Interface IMyFormatting

d.ts

interface IMyFormatting {
   getTitle2Days: (dateFrom: Date, dateTo: Date, locale: string) => string;
}

 

Script

const ret = {
	getTitle2Days: (dateFrom: Date, dateTo: Date, locale: string) => {
 		return `${dateFrom.toLocaleDateString(locale)} - ${dateTo.toLocaleDateString(locale)}`;
	}
};
return ret;

Example 2

(to show sub-property with async/await)

We will return rows from our order table, filtered by status = done.

We will create a sub-property. (We must define the root property as well)

Call should look like

const orders = await doo.myLoading.tables.loadFilteredOrders();

First - the root property.

Name My loading example root

Property name myLoading

Interface IMyLoading

d.ts

interface IMyLoading{
   tables: IMyLoadingTables;
}

interface IMyLoadingTables {
	loadFilteredOrders: () => IDooApiTableOrders[];
}

Script

Leave it empty. Now, we just defined type of doo.myLoading property.

 

And now the doo.myLoading.tables functionality. (In the previous step we defined myLoading property)

Name My loading example table

Property name myLoading.tables

Interface IMyLoadingTables

d.ts

Just leave empty. We already defined the interface in the previous record.

Script

const loadFilteredOrders = async () => {
const result = await doo.table.getData<IDooApiTableANY>('Orders', { filter: 'status(eq)done' });
    return result.data;
};
var ret = {
    loadFilteredOrders: loadFilteredOrders
}
return ret;

Tips

 

Reuse

In case you want to reuse your code in more applications (have your own library), you can create an application with these definitions and distribute them vie Templates.