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.
Download the extension "Scripting Extensions" into your application. That's it.
The "Custom scripts" table is the place, where you can extend the Tabidoo standard scripting support.
The input screen contains this fields:
doo.myFunctions.getNewGuid()
)The best way would be to go through examples.
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;
(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;
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.