Skip to main content

Web Modeler SDK Reference

The web modeler SDK DescriptionDirect link to The web modeler SDK Description

The web modeler SDK is available in the web modeler, It allows users access resources from user interface and execute complexe computational in the user interface run time.

The SDK has the following classes

class Softyflow {}
class Collection {}
class SQLDatabase {}
class SoftyTables {}
class CustomList {}
class Report {}
class Instance {}
class Task {}
class Api {}
class Email {}
class File {}

In the following sections we will explicit each class and the allowed methods.

1 - SoftyflowDirect link to 1 - Softyflow


The Softyflow class has the Softyflow system methods

UsageDirect link to Usage

This class is instantiated by default as object named SF when the user interface is loaded, so you can use methods directly by calling them via object "SF"

//using SF object
let currentMode = this.SF.getSF_mode();

getSF_modeDirect link to getSF_mode

Is a function that return the mode of the running user interface

ReturnsDirect link to Returns

TypeDescription
stringReturn string ('test', 'uat', 'prod')

ExamplesDirect link to Examples

let currentMode = this.SF.getSF_mode();

getSF_VersionDirect link to getSF_Version

Is a function that return the version of the running user interface

ReturnsDirect link to Returns

TypeDescription
stringReturn string ('test', 'uat', 'prod')

ExamplesDirect link to Examples

let currentVersion = this.SF.getSF_Version();

queryParamsDirect link to queryParams

Is a function that return the query parameters

paramsDescription
selectoptional. The fields to select (fields: SF_mode, SF_version, SF_screen)

ParametersDirect link to Parameters

NameTypeDescription
selectstringThe selected fields

ReturnsDirect link to Returns

TypeDescription
stringReturn string

ExamplesDirect link to Examples

let currentMode = this.SF.getSF_mode('SF_mode SF_version');
console.log(currentMode)
// ?SF_mode=test&SF_version=versionId

startProcessDirect link to startProcess

Is a function that start specific process

ParametersDirect link to Parameters

NameTypeDescription
idstringProcess id
bodyobjectJson of process variables

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let variables = {
  "variable1": "value1",
  "variable2": 1,
  "variable3": true
}
await this.SF.startProcess('processId', variables);

saveNewDirect link to saveNew

Is a function that allow to you to save the user interface state

ParametersDirect link to Parameters

NameTypeDescription
idstringinterface id
bodyobjectJson of interface variables

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let variables = {
  "variable1": "value1",
  "variable2": 1,
  "variable3": true
}
await this.SF.saveNew('interfaceId', variables);

saveTaskDirect link to saveTask

Is a function that allow to you to save the task interface state

ParametersDirect link to Parameters

NameTypeDescription
idstringtask id
bodyobjectJson of task variables

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let variables = {
  "variable1": "value1",
  "variable2": 1,
  "variable3": true
}
await this.SF.saveTask('taskId', variables);

validateTaskDirect link to validateTask

Is a function that allow to validate Task

ParametersDirect link to Parameters

NameTypeDescription
idstringtask id
bodyobjectJson of task variables

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let variables = {
  "variable1": "value1",
  "variable2": 1,
  "variable3": true
}
await this.SF.validateTask('taskId', variables);

getUserPendingTaskDirect link to getUserPendingTask

Is a function that allow to get pending Task assigned to connected user.

ParametersDirect link to Parameters

NameTypeDescription
limitstringlimit of result per page.
pagestringnumber of page
dueDatestringrelated date.
fieldsstringfileds.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await this.SF.getUserPendingTask('limit', 'page', 'dueDate', 'fields');

uploadImageDirect link to uploadImage

Is a function that uploads an image to the server using a multipart/form-data POST request.

ParametersDirect link to Parameters

NameTypeDescription
dataFormDataA FormData object containing the image file and any additional metadata.

ReturnsDirect link to Returns

TypeDescription
Promise<object>Returns a Promise that resolves to the response data from the server.

ExamplesDirect link to Examples

const formData = new FormData();
formData.append("profileImage", file);

let response = await SF.utils.uploadImage(formData);
// returns: { success: true, imageUrl: "/uploads/user123.png" }

setListFromCollectionDirect link to setListFromCollection

Is a function that allow to set list of data from a specific collection.

ParametersDirect link to Parameters

NameTypeDescription
collectionstringcollection ID.
criteriaobjectQuery json.
limitstringlimit of result.
sortstringsort option.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let criteria = { 
  firstName: new RegExp("p", "i")
}
await this.SF.setListFromCollection('collectionId', criteria, 10, 'sort');

setListFromCollectionAggregationDirect link to setListFromCollectionAggregation

Is a function that performs an aggregation operation on a specified collection using the provided aggregation pipeline.

ParametersDirect link to Parameters

NameTypeDescription
collectionstringThe name or ID of the target collection to aggregate.
aggregArray<object>An array of aggregation pipeline stages (MongoDB aggregation framework).

ReturnsDirect link to Returns

TypeDescription
Promise<Array>Returns a Promise that resolves to the result of the aggregation query.

ExamplesDirect link to Examples

let results = await SF.utils.setListFromCollectionAggregation("users", [
  { $match: { age: { $gte: 18 } } },
  { $group: { _id: "$country", count: { $sum: 1 } } }
]);
// returns: [ { _id: "USA", count: 42 }, { _id: "FR", count: 18 } ]

setListFromReportDirect link to setListFromReport

Is a function that performs a dynamic aggregation query on a report collection, using filters, sorting, and limit options.

ParametersDirect link to Parameters

NameTypeDescription
reportstringThe ID or name of the report collection.
queryobjectAn object representing filter conditions using custom or MongoDB operators.
[limit]number(Optional) Limits the number of returned documents.
[sort]object(Optional) Sorting options with by field and direction (-1 or 1).

ReturnsDirect link to Returns

TypeDescription
Promise<Array>Returns a Promise that resolves to the result of the aggregation.

ExamplesDirect link to Examples

let result = await SF.utils.setListFromReport("monthly_sales", {
  SF_createdBy: "admin@example.com",
  region: "NA"
}, 10, { by: "createdAt", direction: -1 });
// returns: [ { ... }, { ... } ]

setListFromReportAggregationDirect link to setListFromReportAggregation

Is a function that performs a custom aggregation on a report instance using a provided aggregation pipeline.

ParametersDirect link to Parameters

NameTypeDescription
reportstringThe ID or name of the report collection.
aggregArray<object>The aggregation pipeline to execute.

ReturnsDirect link to Returns

TypeDescription
Promise<Array>Returns a Promise that resolves to the result of the aggregation.

ExamplesDirect link to Examples

let data = await SF.utils.setListFromReportAggregation("monthly_reports", [
  { $match: { status: "completed" } },
  { $group: { _id: "$region", total: { $sum: "$amount" } } }
]);
// returns: [ { _id: "Europe", total: 24000 }, { _id: "Asia", total: 18000 } ]

setListFromSQLDirect link to setListFromSQL

Is a function that allow to set list of data from client database.

ParametersDirect link to Parameters

NameTypeDescription
clientDatabasestringclientDatabase ID.
querystringQuery table.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await this.SF.setListFromSQL('clientDatabaseID', "code='MMA'");

setListFromCustomListDirect link to setListFromCustomList

Is a function that allow to set list of data from CustomList.

ParametersDirect link to Parameters

NameTypeDescription
CustomListstringCustomList ID.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await this.SF.setListFromCustomList('CustomListID');

aggregateQueryDirect link to aggregateQuery

Is a function that allow to set list of data from CustomList.

ParametersDirect link to Parameters

NameTypeDescription
typestringtype of the resource (collection, report, users, projects, external databases).
idstringId of the resource.
queryobjectJson of a value to be matched in the resource.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await this.SF.aggregateQuery('collection', '610c0343f6ebc7ddcb49cc3b', {value : "it"});

deleteFileDirect link to deleteFile

Is a function that allow to delete a file using it ID.

ParametersDirect link to Parameters

NameTypeDescription
idstringId of the resource.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await this.SF.deleteFile('610c0343f6ebc7ddcb49cc3b');

2 - ProjectsDirect link to 2 - Projects


The Projects class has the methods that will allow you to manage the projects.

UsageDirect link to Usage

const projects = new Projects({ mode: 'test' });

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayaggregation array

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let aggregation = [
  {
    "$match": { "status": "active" }
  },
  {
    "$group": {
      "_id": "$category",
      "total": { "$sum": 1 }
    }
  }
]
let results = await projects.aggregate(aggregation);

3 - UsersDirect link to 3 - Users


The Users class has the methods that will allow you to manage the users.

UsageDirect link to Usage

const users = new Users();

findByIdDirect link to findById

Allow to get a user by id.

ParametersDirect link to Parameters

NameTypeDescription
idstringuser id.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let user = await users.findById("userId");

findDirect link to find

Allow to list the users.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery json.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let criteria = { 
  firstName: new RegExp("p", "i")
}
let usersList = await users.find(criteria);

countDirect link to count

Allow to get the count of users.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery json

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let criteria = { 
  blocked: false
}
let count = await users.count(criteria);

findAndCountDirect link to findAndCount

get a list and the count of users

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJson of options.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

OptionsDirect link to Options

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
fieldsSelect specific fields (example: "createdAt email")
limitNumber of instances returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (1) or descending (-1) order (default : -1)

ExamplesDirect link to Examples

let body = {
  criteria: { 
    firstName: new RegExp("p", "i")
  },
  limit: 10,
  page: 0,
  sortBy: "createdAt",
  direction: -1
}
let res = await users.findAndCount(body);
let usersList = res.data;
let count = res.count;

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayaggregation array

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let aggregation = [
  {
    "$match": { "firstName": new RegExp("z", "i") }
  },
  {
    "$project" : {
                    "_id": 1,
                    "firstName": 1,
                    "lastName": 1,
                    "email": 1
                  }
  }
]
let usersList = await users.aggregate([aggregation]);

addRoleDirect link to addRole

Add role to user using user ID & group ID.

ParametersDirect link to Parameters

NameTypeDescription
userIdstringuser ID.
groupidstringgroup ID.
modestringmode of the running user. interface

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await users.addRole("userId","groupId","SF_mode");

removeRoleDirect link to removeRole

Remove role from user using user ID & group ID.

ParametersDirect link to Parameters

NameTypeDescription
userIdstringuser ID.
groupidstringgroup ID.
modestringmode of the running user interface

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await users.removeRole("userId","groupId","SF_mode");

4 - GroupsDirect link to 4 - Groups


The Groups class has the methods that will allow you to manage user groups.

UsageDirect link to Usage

const groups = new Groups();

findByIdDirect link to findById

Find a group by its unique identifier.

ParametersDirect link to Parameters

NameTypeDescription
idstringGroup ID

ReturnsDirect link to Returns

TypeDescription
promiseReturns group data

ExamplesDirect link to Examples

let group = await groups.findById("groupId123");

findDirect link to find

Find groups based on a filter criteria.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectSearch criteria object

ReturnsDirect link to Returns

TypeDescription
promiseReturns array of groups

ExamplesDirect link to Examples

let list = await groups.find({ name: /admin/i });

countDirect link to count

Count the number of groups that match the criteria.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectFilter criteria

ReturnsDirect link to Returns

TypeDescription
promiseReturns count

ExamplesDirect link to Examples

let total = await groups.count({ type: "system" });

findAndCountDirect link to findAndCount

Find groups and return both the results and the total count.

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectRequest body with filters and pagination

ReturnsDirect link to Returns

TypeDescription
promiseReturns object { data, count }

ExamplesDirect link to Examples

let result = await groups.findAndCount({ limit: 10, offset: 0 });

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results.

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayAggregation pipeline array

ReturnsDirect link to Returns

TypeDescription
promiseReturns aggregation result

ExamplesDirect link to Examples

let aggregation = [
  { $match: { type: "system" } },
  { $group: { _id: "$status", total: { $sum: 1 } } }
];
let stats = await groups.aggregate(aggregation);

groupUsersDirect link to groupUsers

Retrieve the users belonging to a specific group.

ParametersDirect link to Parameters

NameTypeDescription
idstringGroup ID

ReturnsDirect link to Returns

TypeDescription
promiseReturns array of users in the group

ExamplesDirect link to Examples

let users = await groups.groupUsers("groupId123");

5 - CollectionDirect link to 5 - Collection


The collection class has the methods that will allow you to manage your collection

UsageDirect link to Usage

You can instantiate a Collection class with id or name of collection. You can add mode option

OptionDescription
idRequired. id or name of collection
modeoptional. Specifies mode of collection (default : "test")
const collection = new Collection({ id: 'collectionId', mode: this.SF_mode });

insertDirect link to insert

Allow to insert a json into a collection

ParametersDirect link to Parameters

NameTypeDescription
dataobjectJson of a value to be inserted in to the collection.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await collection.insert({ name: "name1", type : "type1" });

insertManyDirect link to insertMany

Allow to insert an array of json in to a collection.

ParametersDirect link to Parameters

NameTypeDescription
dataobjectJson of a value to be inserted in to the collection.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await collection.insertMany([{label : "IT", value : "it"}]);

updateManyDirect link to updateMany

update all the documents that satisfies the specified query criteria .

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery json.
dataobjectJson of a new data.
optionsobjectJson of options

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let criteria = { 
  firstName: new RegExp("p", "i")
}
await collection.updateMany(criteria, [{ type : "type2" }], { upsert: true });

updateDirect link to update

Allow to update a document in collection

ParametersDirect link to Parameters

NameTypeDescription
idstringDocument id.
dataobjectJson of a new data.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await collection.update("documentId", { type : "type2" });

deleteDirect link to delete

Allow to delete a document from collection

ParametersDirect link to Parameters

NameTypeDescription
idstringDocument id.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await collection.delete("documentId");

findByIdDirect link to findById

Allow to get a object by id from the collection

ParametersDirect link to Parameters

NameTypeDescription
idstringDocument id.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let document = await collection.findById(id);

findDirect link to find

Allow to select the documents in a collection

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJson of options.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

OptionsDirect link to Options

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
limitNumber of documents returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (1) or descending (-1) order (default : -1)

ExamplesDirect link to Examples

let body = {
  criteria: { 
    name: new RegExp("p", "i"), 
    type: "type1" 
  },
  limit: 10,
  page: 0,
  sortBy: "createdAt",
  direction: -1
}
let documents = await collection.find(body);

countDirect link to count

Allow to get the count of documents that would match a query for the collection

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery json

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let count = await collection.count({ type: "type1" });

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayaggregation array

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let aggregation = [
  {
    "$match": { "type": "type1" }
  },
  {
    "$project" : {
                    "_id": 1,
                    "name": 1
                  }
  }
]
let documents = await collection.aggregate([aggregation]);

6 - SQLDatabaseDirect link to 6 - SQLDatabase


Manage your external SQL Databases Through the SQLDatabase class.

UsageDirect link to Usage

You can instantiate an SQL class with id and mode(optional).

OptionDescription
idRequired. id or name of Database
modeoptional. Specifies mode of Database (default : "test")
const sql = new SQLDatabase({ id: '610c0343f6ebc7ddcb49cc3b', mode: this.SF_mode});

findOneDirect link to findOne

Get a table row data

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
Criteriastringquery table.

ReturnsDirect link to Returns

TypeDescription
object

ExamplesDirect link to Examples

let res = await sql.findOne("client", "code='MMA'"))

findDirect link to find

list multiple rows from sql table

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
optionsstringquery table.

ReturnsDirect link to Returns

TypeDescription
array

ExamplesDirect link to Examples

let res = sql.find("client", "code='MMA'")

countDirect link to count

Get the row count for a table with a criteria

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
optionsstringquery table.

ReturnsDirect link to Returns

TypeDescription
arrayarray with one element contining count

ExamplesDirect link to Examples

let count = await sql.count("client", "code='MMA'");

executeDirect link to execute

Execute a custom query on the database.

ParametersDirect link to Parameters

NameTypeDescription
querystringstring of query.

ReturnsDirect link to Returns

TypeDescription
arrayReturn array.

ExamplesDirect link to Examples

sql.execute("INSERT INTO client(code, intitule, representant, codepostal) VALUES('MDSX', 'holder', 'holder', 14000)")

insertDirect link to insert

Insert one row into a table.

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
dataobjectJSON body.

ReturnsDirect link to Returns

TypeDescription
array

ExamplesDirect link to Examples

sql.insert("client", {
    code: 'HelloWord',
    codepostal: 14000
}

insertManyDirect link to insertMany

Insert multiple rows into

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
dataarrayJSON body.

ReturnsDirect link to Returns

TypeDescription
array

ExamplesDirect link to Examples

sql.insertMany("client", [
  { code: '#1' },
  { code: '#2' }
])

updateDirect link to update

Update rows.

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
querystringquery table.
dataobjectupdated JSON body.

ReturnsDirect link to Returns

TypeDescription
object

ExamplesDirect link to Examples

 sql.update('client',   "code='MMA'",
    {
        code: "MQS"
    })

deleteDirect link to delete

Delete row/rows in your table.

ParametersDirect link to Parameters

NameTypeDescription
tableNamestringtable name.
querystringquery table.

ReturnsDirect link to Returns

TypeDescription
object

ExamplesDirect link to Examples

sql.delete("client", "id=223")

7 - SoftyTablesDirect link to 7 - SoftyTables


The SoftyTables class provides methods to interact with SoftyTable resources, allowing you to perform CRUD operations, execute queries, and manage table data from the web interface.

UsageDirect link to Usage

You can instantiate a SoftyTables class with id and mode options.

OptionDescription
idRequired. id of the SoftyTable
modeoptional. Specifies mode of SoftyTable (default : "test")
const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

findByIdDirect link to findById

Retrieve a single row from a SoftyTable by its ID.

ParametersDirect link to Parameters

NameTypeDescription
rowIdstringThe ID of the row

ReturnsDirect link to Returns

TypeDescription
promiseResolves to the row data

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});
let row = await softyTable.findById('12345');

findDirect link to find

List rows from a SoftyTable with optional filtering, sorting, and pagination.

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJSON of options (criteria, limit, page, sortby, direction)

ReturnsDirect link to Returns

TypeDescription
promiseResolves to an array of table rows

OptionsDirect link to Options

These options are optional

OptionDescription
criteriaSpecifies selection filter with where clause (default : {})
limitNumber of rows returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by field name (default : createdAt)
directionAscending (1) or descending (-1) order (default : -1)

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// List all rows
let rows = await softyTable.find({});

// List with filters and pagination
let body = {
  criteria: { 
    where: { status: 'active' } 
  },
  limit: 50,
  page: 0,
  sortby: 'createdAt',
  direction: -1
}
let activeRows = await softyTable.find(body);

countDirect link to count

Count the number of rows in a SoftyTable with optional filtering.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery criteria with optional where clause

ReturnsDirect link to Returns

TypeDescription
promiseResolves to an object with count property

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Count all rows
let result = await softyTable.count({});
// returns: { count: 150 }

// Count with filter
let result = await softyTable.count({ 
  criteria: { where: { status: 'active' } }
});
// returns: { count: 75 }

findAndCountDirect link to findAndCount

Get both a list of rows and the total count matching the criteria.

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJSON of options (criteria, limit, page, sortby, direction)

ReturnsDirect link to Returns

TypeDescription
promiseResolves to object { data, count }

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let body = {
  criteria: { 
    where: { status: 'active' } 
  },
  limit: 10,
  page: 0,
  sortby: 'createdAt',
  direction: -1
}
let result = await softyTable.findAndCount(body);
let rows = result.data;
let count = result.count;

insertDirect link to insert

Create a single row in a SoftyTable.

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectThe data object to insert as a row

ReturnsDirect link to Returns

TypeDescription
promiseResolves to the created row data

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let newRow = await softyTable.insert({
  name: 'John Doe',
  email: 'john@example.com',
  age: 30,
  status: 'active'
});

insertManyDirect link to insertMany

Create multiple rows in a SoftyTable at once.

ParametersDirect link to Parameters

NameTypeDescription
dataarrayArray of data objects to insert

ReturnsDirect link to Returns

TypeDescription
promiseResolves to an array of created rows

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let newRows = await softyTable.insertMany([
  { name: 'John Doe', email: 'john@example.com', age: 30 },
  { name: 'Jane Smith', email: 'jane@example.com', age: 25 },
  { name: 'Bob Johnson', email: 'bob@example.com', age: 35 }
]);

updateDirect link to update

Update a single row in a SoftyTable by its ID.

ParametersDirect link to Parameters

NameTypeDescription
rowIdstringThe ID of the row to update
bodyobjectThe fields and values to update

ReturnsDirect link to Returns

TypeDescription
promiseResolves to the updated row

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let updated = await softyTable.update('12345', {
  status: 'inactive',
  updatedAt: new Date()
});

updateManyDirect link to updateMany

Update multiple rows in a SoftyTable that match specific criteria.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery criteria with where clause
valueobjectThe fields and values to update
optionsobjectAdditional options (optional)

ReturnsDirect link to Returns

TypeDescription
promiseResolves to update operation result

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Update all rows where status is 'pending'
let result = await softyTable.updateMany(
  { status: 'pending' },
  { status: 'active', processedAt: new Date() }
);

deleteDirect link to delete

Delete a single row from a SoftyTable by its ID.

ParametersDirect link to Parameters

NameTypeDescription
rowIdstringThe ID of the row

ReturnsDirect link to Returns

TypeDescription
promiseResolves to deletion result

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

await softyTable.delete('12345');

deleteManyDirect link to deleteMany

Delete multiple rows from a SoftyTable that match specific criteria.

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery criteria with where clause

ReturnsDirect link to Returns

TypeDescription
promiseResolves to deletion result

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Delete all inactive rows
await softyTable.deleteMany({ status: 'inactive' });

// Delete rows older than a certain date
await softyTable.deleteMany({ 
  createdAt: { $lt: new Date('2024-01-01') } 
});

clearDirect link to clear

Clear all rows from a SoftyTable (delete all data).

ReturnsDirect link to Returns

TypeDescription
promiseResolves to deletion result

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Remove all rows from the table
await softyTable.clear();

getOptionsDirect link to getOptions

Retrieve options for select fields in a SoftyTable.

ReturnsDirect link to Returns

TypeDescription
promiseResolves to array of options

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let options = await softyTable.getOptions();
// returns: [{ label: 'Active', value: 'active' }, { label: 'Inactive', value: 'inactive' }]

executeDirect link to execute

Execute a custom SQL query on the SoftyTable.

ParametersDirect link to Parameters

NameTypeDescription
querystringThe SQL query to execute
optionsobjectQuery options with replacements and type

Options ObjectDirect link to Options Object

FieldTypeDescription
replacementsobjectValues to replace in parameterized queries
typestringQuery type: 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RAW', 'SHOWTABLES'

ReturnsDirect link to Returns

TypeDescription
promiseResolves to the query results

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

// Execute a SELECT query
let results = await softyTable.execute(
  'SELECT * FROM my_table WHERE status = :status',
  {
    replacements: { status: 'active' },
    type: 'SELECT'
  }
);

// Execute a custom query
let results = await softyTable.execute(
  'UPDATE my_table SET status = "processed" WHERE created_at < NOW() - INTERVAL 30 DAY',
  { type: 'UPDATE' }
);

migrateDirect link to migrate

Migrate rows in a SoftyTable (for data migration operations).

ReturnsDirect link to Returns

TypeDescription
promiseResolves to migration result

ExamplesDirect link to Examples

const softyTable = new SoftyTables({id: 'tableId', mode: 'test'});

let result = await softyTable.migrate();

8 - CustomListDirect link to 8 - CustomList


The CustomList class has the methods that will allow you to manage your Custom List

UsageDirect link to Usage

You can instantiate a CustomList class with id of custom list. You can add other options (mode, versionId)

OptionDescription
idRequired. id of custom list
modeoptional. Specifies mode of custom list (default : "test")
versionIdoptional. id of the version from which to get the custom list
const customList = new CustomList({id: 'id', mode: 'test', versionId: "vId"});

getDirect link to get

Get a custom list data

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let customListData = await customList.get();

9 - ReportDirect link to 9 - Report


The Report class will allow you to manipulate specific report

UsageDirect link to Usage

You can instantiate a Report class with id of report. You can add mode option

OptionDescription
idRequired. Specifies mode of custom list (default : "test")
modeoptional. Specifies mode of custom list (default : "test")
const report = new Report({id: 'id', mode: 'test'});

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayaggregation array

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let aggregation = [
  {
    "$match": { "SF_status": "Running" }
  },
  { 
    "$sort": { "SF_createdAt": -1 } 
  }
]
let instances = await report.aggregate(aggregation);  //report of instances

10 - InstanceDirect link to 10 - Instance


The Instance class has the methods that will allow you to manage the instances

UsageDirect link to Usage

const instance = new Instance();

findByIdDirect link to findById

Get a instance by id

ParametersDirect link to Parameters

NameTypeDescription
idstringid of instance.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let oneInstance = await instance.findById(id);

findDirect link to find

list the instances

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectJson of query.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let instances = await instance.find({ status: "Running" });

countDirect link to count

Allow to get the count of instances that would match a query

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery json

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let count = await instance.count({ status: "Running" });

findAndCountDirect link to findAndCount

get a list and the count of instances

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJson of options.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

OptionsDirect link to Options

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
fieldsSelect specific fields (example: "createdAt name status")
limitNumber of instances returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (1) or descending (-1) order (default : -1)

ExamplesDirect link to Examples

let body = {
  criteria: { 
    status: "Running" 
  },
  limit: 10,
  page: 0,
  sortBy: "createdAt",
  direction: -1
}
let res = await instance.findAndCount(body);
let instances = res.data;
let count = res.count;

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayaggregation array

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let aggregation = [
  {
    "$match": { "status": "End" }
  },
  {
    "$project" : {
                    "_id": 1,
                    "name": 1
                  }
  }
]
let instances = await instance.aggregate([aggregation]);

updateDirect link to update

Update an instance

ParametersDirect link to Parameters

NameTypeDescription
idstringid of instance.
dataobjectJson of a new data.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await instance.update(id, { status : "End" });

deleteDirect link to delete

Delete an instance

ParametersDirect link to Parameters

NameTypeDescription
idstringid of instance.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await instance.delete(id);

historyDirect link to history

Get instance history.

ParametersDirect link to Parameters

NameTypeDescription
idstringid of instance.
dataobjectJson of data.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await instance.history(id, { status : "End" });

11 - TaskDirect link to 11 - Task


The Task class has the methods that will allow you to manage the tasks

UsageDirect link to Usage

const task = new Task();

findByIdDirect link to findById

Get a task by id

ParametersDirect link to Parameters

NameTypeDescription
idstringid of task.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let oneTask = await task.findById(id);

findDirect link to find

list the tasks

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectJson of query.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let tasks = await task.find({ instanceId: "instanceId" });

countDirect link to count

Allow to get the count of tasks that would match a query

ParametersDirect link to Parameters

NameTypeDescription
criteriaobjectQuery json

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let count = await task.count({ instanceId: "instanceId" });

findAndCountDirect link to findAndCount

get a list and the count of tasks

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJson of options.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

OptionsDirect link to Options

This options are optional

OptionDescription
criteriaSpecifies selection filter (default : {})
assignedToConnectedTo get tasks of connected user (default : false)
fieldsSelect specific fields (example: "createdAt name status")
limitNumber of instances returned (default : 100/ no limit : 0)
pagePage number depends on the limit (default : 0)
sortbySorts the results by key (default : createdAt)
directionAscending (1) or descending (-1) order (default : -1)

ExamplesDirect link to Examples

let body = {
  criteria: { 
    status: "Running" 
  },
  assignedToConnected: true,
  limit: 10,
  page: 0,
  sortBy: "createdAt",
  direction: -1
}
let res = await task.findAndCount(body);
let tasks = res.data;
let count = res.count;

aggregateDirect link to aggregate

Aggregation operations process data records and return computed results

ParametersDirect link to Parameters

NameTypeDescription
aggregationarrayaggregation array

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let aggregation = [
  {
    "$match": { "status": "End" }
  },
  {
    "$project" : {
                    "_id": 1,
                    "name": 1
                  }
  }
]
let tasks = await task.aggregate([aggregation]);

updateDirect link to update

Update an task

ParametersDirect link to Parameters

NameTypeDescription
idstringid of task.
dataobjectJson of a new data.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await task.update(id, { status : "End" });

deleteDirect link to delete

Delete an task

ParametersDirect link to Parameters

NameTypeDescription
idstringid of task.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await task.delete(id);

getNextValueDirect link to getNextValue

Get next value of an task.

ParametersDirect link to Parameters

NameTypeDescription
namestringname of the variable.
[padding]numberPadding of result with 000000.
modestringmode of the running user.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await task.getNextValue("name",5,"SF_mode");

historyDirect link to history

Get the history of a task by its ID.

ParametersDirect link to Parameters

NameTypeDescription
idstringTask ID
bodyobjectQuery parameters (optional)

ReturnsDirect link to Returns

TypeDescription
promiseReturns object { data, count }

ExamplesDirect link to Examples

let log = await task.history("taskId123", {});

12 - ApiDirect link to 12 - Api


The Api class has the methods that will allow you to manage your Apis.

UsageDirect link to Usage

const api = new Api();

invokeDirect link to invoke

Invoke an api.

ParametersDirect link to Parameters

NameTypeDescription
bodyobjectJson of options.

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

let body = {
  const myElement = document.getElementById("demo");

  function getLocation() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(showPosition);
    } else {
      myElement.innerHTML = "Geolocation is not supported by this browser.";
    }
  }

  function showPosition(position) {
    myElement.innerHTML = "Latitude: " + position.coords.latitude +
    "<br>Longitude: " + position.coords.longitude;
  }
}
await api.invoke(body);

13 - EmailDirect link to 13 - Email


The Email class has the methods that will allow you to manage your emails.

UsageDirect link to Usage

const email = new Email();

sendDirect link to send

Send an email.

ParametersDirect link to Parameters

NameTypeDescription
assigneestringAssignee user email.
subjectstringSubject of the email.
variablesobjectJson of options.
mailTemplateobjectEmail template.
mailProviderobjectSoftyflow default provider.
ccstringJson of options.
fromstringSender user email.
replyTostring*

ReturnsDirect link to Returns

TypeDescription
promiseReturn promise

ExamplesDirect link to Examples

await email.send("assignee","subject",{"var1", "var2"},{"mailTemplate"},{"mailProvider"},"mail of user in cc", "senderMail","replyTo");

14 - DataSourceDirect link to 14 - DataSource


The DataSource class provides generic data manipulation methods for various sources such as collections, tables, or reports.

UsageDirect link to Usage

const ds = new DataSource();

findOneDirect link to findOne

Retrieve a single document from a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
optionsobjectQuery options

ReturnsDirect link to Returns

TypeDescription
promiseReturns a single document

ExamplesDirect link to Examples

let doc = await ds.findOne("users", { filter: { email: "user@example.com" } });

listDirect link to list

List multiple documents from a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
optionsobjectQuery options

ReturnsDirect link to Returns

TypeDescription
promiseReturns an array of documents

ExamplesDirect link to Examples

let docs = await ds.list("users", { filter: { active: true } });

countDirect link to count

Count the number of documents in a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
optionsobjectQuery options

ReturnsDirect link to Returns

TypeDescription
promiseReturns the count of documents

ExamplesDirect link to Examples

let total = await ds.count("orders", { filter: { status: "delivered" } });

updateDirect link to update

Update documents in a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
optionsobjectQuery conditions
dataobjectData to update

ReturnsDirect link to Returns

TypeDescription
promiseReturns update result

ExamplesDirect link to Examples

await ds.update("products", { filter: { stock: 0 } }, { restock: true });

insertDirect link to insert

Insert a single document into a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
dataobjectDocument to insert
optionsobjectAdditional options

ReturnsDirect link to Returns

TypeDescription
promiseReturns insert result

ExamplesDirect link to Examples

await ds.insert("logs", { action: "login", userId: "abc123" });

insertManyDirect link to insertMany

Insert multiple documents into a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
dataarrayArray of documents
optionsobjectAdditional options

ReturnsDirect link to Returns

TypeDescription
promiseReturns insert result

ExamplesDirect link to Examples

await ds.insertMany("logs", [{ action: "view" }, { action: "edit" }]);

deleteDirect link to delete

Delete documents from a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
optionsobjectDelete criteria

ReturnsDirect link to Returns

TypeDescription
promiseReturns delete result

ExamplesDirect link to Examples

await ds.delete("sessions", { filter: { expired: true } });

executeDirect link to execute

Execute a custom action or command on a data source.

ParametersDirect link to Parameters

NameTypeDescription
sourcestringName of the source
optionsobjectParameters for execution

ReturnsDirect link to Returns

TypeDescription
promiseReturns execution result

ExamplesDirect link to Examples

await ds.execute("jobs", { action: "resetAll" });

15 - FileDirect link to 15 - File

The File class provides methods for generating PDF files from stored HTML templates and variable contexts using API endpoints.


generatePDFDirect link to generatePDF

Generates a PDF file by retrieving the HTML content of a file and posting it along with contextual data.

ParametersDirect link to Parameters

NameTypeDescription
filenamestring- Desired name for the generated PDF
fidstring- File ID to fetch content from
contextobject- Contextual data for PDF rendering (e.g., variables)

ReturnsDirect link to Returns

TypeDescription
Promise- Resolves with the PDF generation response

ExampleDirect link to Example

const file = new File();
file.generatePDF("output.pdf", "605c72...", { variables: { user: "Alice" } });

genratePDFWithVarDirect link to genratePDFWithVar

Generates PDF content using variables directly by posting to a specific content generation endpoint.

ParametersDirect link to Parameters

NameTypeDescription
namestring- Name for the output (not directly used in the call)
fidstring- File ID of the template
contextobject- Variable data used for rendering the template

ReturnsDirect link to Returns

TypeDescription
Promise- Resolves with the server response

ExampleDirect link to Example

const file = new File();
file.genratePDFWithVar("Invoice", "605c72...", { variables: { amount: 100, user: "Alice" } });