The process modeler SDK is available in any input or output variables in the process modeler, It allows users access resources from process and execute complexe computational in the instance run time.
The SDK can be accessed trought the SF variable.
The SDK has the following attributs
var SF = {
collection : Object,
user : Object,
file : Object,
utils : Object,
sql : Object,
instance : Object,
task : Object,
process : Object,
softyTable : Object,
mode : String,
};
In the following sections we will explicit each attribute and the allowed methods.
1 - Utilsโ
The utils object has the methods that will allow you to
nextValueโ
Generates an incremental number based on a unique string name. The resulting ID can be zero-padded to a specified length if desired.
Parametersโ
| Name | Type | Description |
|---|
| name | string | A unique name used as the key to generate the ID. |
| padding | number | (Optional) The number of digits to pad the result with (e.g., 6 โ 000001). |
Returnsโ
| Type | Description |
|---|
| Promise | A Promise that resolves to the generated ID. |
Examplesโ
let id = await SF.utils.nextValue("leave_request");
let id = await SF.utils.nextValue("leave_request",5);
shellExecLocalโ
Is a function that executes a local shell command and returns the trimmed output.
Parametersโ
| Name | Type | Description |
|---|
cmd | string | The shell command to be executed. |
Returnsโ
| Type | Description |
|---|
Promise<{data: string}> | A Promise that resolves to an object containing the trimmed standard output. |
Examplesโ
let result = await SF.utils.shellExecLocal('echo Hello World');
let result = await SF.utils.shellExecLocal('pwd');
shellExecRemoteโ
Is a function that executes a shell command on a remote server.
Parametersโ
| Name | Type | Description |
|---|
cdm | string | The shell command to be executed remotely. |
options | object | SSH connection options (host, port, username, password/privateKey, etc.). |
Returnsโ
| Type | Description |
|---|
Promise<{data: string, code: number}> | A Promise that resolves to an object containing: โ data: The standard output result as a string. โ code: The exit code of the remote command. |
Examplesโ
let result = await SF.utils.shellExecRemote('ls -l', {
host: '192.168.1.10',
port: 22,
username: 'user',
password: 'password'
});
Axios is a Promise based HTTP client for the browser and node.js
Lean more See the official documentation
Examplesโ
let id = SF.utils.axios.get('/data/json/123')
.then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
2 - Collectionโ
insertManyโ
Allow to insert an array of json in to a collection
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
data | array | Array of data to be inserted into the collection. |
Returnsโ
| Type | Description |
|---|
Promise | A Promise indicating the result of the insert operation. |
Examplesโ
await SF.collection.insertMany("cost-centers",[{label : "IT", value : "it"}])
insertOneโ
Allow to insert a json in to a collection
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
data | object | JSON object representing a single value to be inserted into the collection. |
Returnsโ
| Type | Description |
|---|
Promise | A Promise indicating the result of the insert operation. |
Examplesโ
await SF.collection.insertOne("cost-centers",{label : "IT", value : "it"})
findOneโ
Returns one document that satisfies the specified query criteria . If multiple documents satisfy the query, this method returns the first document.
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
query | object | JSON object of values to be matched in the collection. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.collection.findOne("cost-centers",{value : "it"})
Returns all the documents that satisfies the specified query criteria .
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
query | object | JSON object representing the criteria to match documents in the collection. |
Returnsโ
| Type | Description |
|---|
Promise | A Promise indicating the result of the find operation. |
Examplesโ
await SF.collection.find("cost-centers",{value : "it"})
updateOneโ
update the first document that satisfies the specified query criteria .
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
query | object | JSON object representing the criteria to match documents in the collection. |
body | object | JSON object representing the fields and values to update. |
Returnsโ
| Type | Description |
|---|
Promise | A Promise indicating the result of the update operation. |
Examplesโ
await SF.collection.updateOne("cost-centers",{value : "it"})
update all the documents that satisfies the specified query criteria .
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
query | object | JSON object representing the value to match in the collection. |
body | object | JSON object representing the value to update in the collection. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
await SF.collection.update("cost-centers",{value : "it"})
Returns the count of documents in the collection.
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
await SF.collection.count("cost-centers")
deleteOneโ
Allow to delete a document from collection.
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
query | object | JSON object representing the value to match in the collection. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
await SF.collection.deleteOne("cost-centers",{})
Allow to delete multiple documents from collection.
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
query | object | JSON object representing the value to match in the collection. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
await SF.collection.delete("cost-centers",{})
aggregateโ
Aggregation operations process data records and return computed results
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
aggregation | array | Aggregation array. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
let aggregation = [
{
"$match": { "type": "type1" }
},
{
"$project" : {
"_id": 1,
"name": 1
}
}
]
await SF.collection.aggregate("cost-centers",[aggregation]);
cleanCollectionโ
Remove All Documents from a Collection.
Parametersโ
| Name | Type | Description |
|---|
collection | string | Collection name in Softyflow. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
await SF.collection.cleanCollection("cost-centers")
bulkWriteโ
Is a function that performs multiple write operations (insert, update, delete) in a single batch on a specified MongoDB collection.
Parametersโ
| Name | Type | Description |
|---|
col | string | The name of the collection (without suffix). |
bulkOps | Array | An array of bulk write operations (insertOne, updateOne, deleteOne, etc.). |
Returnsโ
| Type | Description |
|---|
Promise | Returns a Promise that resolves once all bulk operations are complete. |
Examplesโ
let bulkOps = [
{ insertOne: { document: { name: 'John', age: 30 } } },
{ updateOne: { filter: { name: 'John' }, update: { $set: { age: 31 } } } },
{ deleteOne: { filter: { name: 'John' } } }
];
await SF.utils.bulkWrite('users', bulkOps);
3 - Usersโ
getUsersinGroupโ
Get all users in a given group
Parametersโ
| Name | Type | Description |
|---|
group | string | Group ID. |
Returnsโ
| Type | Description |
|---|
Promise | Returns a promise. |
Examplesโ
await SF.user.getUsersinGroup("6042551d231e8c8ade19bc09")
getUsersInGroupListโ
get the users who exist in certain groups.
Parametersโ
| Name | Type | Description |
|---|
groups | string[] | Array of groupID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.getUsersInGroupList(["6042551d231e8c8ade19bc09","6040e3679c81cf1b60b698f4"])
getGroupByIdโ
Is a function that retrieves a group document from the "groups" collection by its unique ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | The ID of the group to be retrieved. |
Returnsโ
| Type | Description |
|---|
| `Promise<object | null>` |
Examplesโ
let group = await SF.utils.getGroupById("60c72b2f9f1b2c3c8f3b8b0b");
let group = await SF.utils.getGroupById("60c72b2f9f1b2c3c8f3b8b0c");
getUserByIdโ
Get user information using his id.
Parametersโ
| Name | Type | Description |
|---|
id | string | User ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.getUserById("6042551d231e8c8ade19bc09")
getUserByMailโ
Get user information using his email.
Parametersโ
| Name | Type | Description |
|---|
email | string | User email. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.getUserByMail("test@softyflow.com")
updateUserByIdโ
Update user information using his ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | User ID. |
data | object | JSON object of values to update. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.updateUserById("6042551d231e8c8ade19bc09",{firstName : "test"})
updateUsersEachโ
Update a list of users individualy : to each user their own payload.
Parametersโ
| Name | Type | Description |
|---|
Array | Array | Array of objects, each containing a user ID and a payload. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.updateUsersEach([{ _id: "6042551d231e8c8ade19bc09", payload: { firstName: 'firstUser' } }, { _id: "6042551d231e8c8ade19bc10", payload: { firstName: 'secondUser' } }])
Update user metadata using his ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | User ID. |
field | object | JSON object of metadata to update. |
value | object | JSON object of values to be updated. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.updateUserMetadataById("6042551d231e8c8ade19bc09", "Manager", "test")
getUsersโ
Get users informations.
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
Get user metadata using his ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | User ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.getUserMetadata("6042551d231e8c8ade19bc09")
addUserToGroupโ
Add user to a groupe using user ID & group ID.
Parametersโ
| Name | Type | Description |
|---|
userId | string | User ID. |
groupid | string | Group ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.addUserToGroup("6042551d231e8c8ade19bc09", "62c2b6f74d16c2a2c19dcdb7")
removeUserfromGroupโ
Remove user from group using user ID & group ID.
Parametersโ
| Name | Type | Description |
|---|
userId | string | User ID. |
groupid | string | Group ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.user.removeUserfromGroup("6042551d231e8c8ade19bc09", "62c2b6f74d16c2a2c19dcdb7")
createUserโ
Allow to create new user.
Parametersโ
| Name | Type | Description |
|---|
data | object | JSON content user data |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
This is the allowed user data:
| field | Description |
|---|
| email | Required and Unique. The user email (string) |
| lastName | Required. The user last name (string) |
| firstName | Required. The user first name (string) |
| group | Required. The user production groups ids (array) |
| group_test | Optional. The user test groups ids (array) |
| group_uat | Optional. The user UAT groups ids (array) |
| metadata_test | Optional. The user test metadata (json) |
| metadata_uat | Optional. The user UAT metadata (json) |
| metadata_prod | Optional. The user production metadata (json) |
| ideAccess | Required. IDE access right (boolean) |
| blocked | Optional. User blocking (boolean) |
| sendMail | Optional. Send email notification to the user (boolean) |
| getPassword | Optional. Get the generated password in response (boolean) |
Examplesโ
var newUser = {
firstName: "Jean",
lastName: "Martin",
email: "jean.martin@softy.io",
group_test: [],
group_uat: [],
group: [],
metadata_test: {},
metadata_uat: {},
metadata_prod: {},
ideAccess: false,
blocked: false,
sendMail: false,
getPassword: false
};
var user = await SF.user.createUser(newUser);
The File class manages files stored in MongoDB's GridFS system, providing methods to upload, retrieve, delete, and generate PDFs from EJS templates.
getFileContentByIdโ
Retrieve the text content of a file by its ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | File ObjectId |
encoding | string | Encoding to use (default: 'utf8') |
Returnsโ
| Type | Description |
|---|
Promise<object> | File metadata with content field |
Exampleโ
let result = await SF.file.getFileContentById("64bfa28cfabc123...", "utf8");
console.log(result.content);
getFileBufferByIdโ
Retrieve the binary content of a file as a Buffer.
Parametersโ
| Name | Type | Description |
|---|
id | string | File ObjectId |
Returnsโ
| Type | Description |
|---|
Promise<Buffer> | File data as Buffer |
Exampleโ
let buffer = await SF.file.getFileBufferById("64bfa28cfabc123...");
generatePDFFromTemplateโ
Generate a PDF from a stored EJS template file and save it back to GridFS.
Parametersโ
| Name | Type | Description |
|---|
dump_var | any | Not used |
fid | string | Template file ID |
context | object | PDF generation context |
Returnsโ
| Type | Description |
|---|
Promise<object> | Metadata of saved PDF file |
context.variables: Variables injected into the template.context.SF_pdfName: Optional name for the generated PDF.
Exampleโ
await SF.file.generatePDFFromTemplate(null, 'templateId', {
variables: { name: "John" },
SF_pdfName: "user-report.pdf"
});
createFileFromBufferโ
Create and upload a file from a Buffer.
Parametersโ
| Name | Type | Description |
|---|
fileMetadata | object | Metadata (filename, contentType, etc.) |
bufferContent | Buffer | Binary content of the file |
Returnsโ
| Type | Description |
|---|
Promise<object> | Metadata of saved file |
Exampleโ
await SF.file.createFileFromBuffer({ filename: "doc.txt", contentType: "text/plain" }, Buffer.from("Hello"));
fillTemplateโ
Fill a document template (Word, Excel, LibreOffice, etc.) with data using the Carbone rendering engine. This method takes a template file stored in the database, merges it with the provided data, and creates a new filled document.
Parametersโ
| Name | Type | Description |
|---|
id | string | Template file ObjectId |
data | object | JSON data to inject into the template |
Returnsโ
| Type | Description |
|---|
Promise<string> | File ID of the newly created filled document |
Template Creationโ
To create templates compatible with this method:
- Use standard office software (Microsoft Office, LibreOffice, OpenOffice)
- Insert placeholders using the Carbone syntax:
{d.fieldName} - Supported formats: DOCX, XLSX, PPTX, ODT, ODS, ODP, and more
For detailed information on template creation and advanced features (loops, conditions, formatters), see the official Carbone documentation.
Exampleโ
let data = {
customerName: "John Doe",
amount: 1500,
date: "2025-01-15",
items: [
{ product: "Widget A", quantity: 5, price: 100 },
{ product: "Widget B", quantity: 10, price: 50 }
]
};
let filledDocumentId = await SF.file.fillTemplate("64bfa28cfabc123...", data);
console.log("Filled document ID:", filledDocumentId);
Advanced Template Featuresโ
The Carbone engine supports advanced features:
- Loops: Repeat sections for arrays of data
- Conditions: Show/hide content based on data
- Formatters: Format dates, numbers, text
- Nested objects: Access nested data structures
- Calculations: Perform calculations in templates
Example template with loops:
Invoice Items:
{d.items[i].product} - Qty: {d.items[i].quantity} - Price: {d.items[i].price}
For more information, visit Carbone.io Documentation.
deleteFileByIdโ
Is a function that deletes a file from the database by its unique ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | The ID of the file to be deleted. |
Returnsโ
| Type | Description |
|---|
Promise<object> | Resolves to an object indicating deletion status: { deleted: 1 } if successful, { deleted: 0 } if failed. |
Examplesโ
let result = await SF.file.deleteFileById("60c72b2f9f1b2c3c8f3b8b0b");
let result = await SF.file.deleteFileById("60c72b2f9f1b2c3c8f3b8b0c");
5 - Sqlโ
insertOneโ
Insert a row into your SQL Table
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
data | object | Data to insert into database. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.insertOne("610c0343f6ebc7ddcb49cc3b", "client", {
code: 'MMA',
codepostal: 225
})
insertManyโ
Insert an array of rows into your SQL Table
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
data | array | Data to insert into database. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.insertMany("610c0343f6ebc7ddcb49cc3b", "client", [{
code: 'MMA',
codepostal: 225
}])
findOneโ
Find data in your SQL table.
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
name | string | Table name. |
data | string | Criteria to query database. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.findOne("610c0343f6ebc7ddcb49cc3b", "client", "code='MGMT'")
Find all rows in your SQL table that match a certain criteria.
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
name | string | Table name. |
data | string | Criteria to query database. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.find("610c0343f6ebc7ddcb49cc3b", "client", "code='MGMT'")
Update data in your database.
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
name | string | Table name. |
data | string | Criteria to query database. |
newData | object | Updated data. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.update("610c0343f6ebc7ddcb49cc3b", "client", "code='MDMS'", {
code: 'CLEA'
})
Delete rows from your database.
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
name | string | Table name. |
data | string | Criteria to query database. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.delete("610c0343f6ebc7ddcb49cc3b", "client", "code='CLEA'")
count rows in your database.
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
name | string | Table name. |
data | string | Criteria to query database. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.count("610c0343f6ebc7ddcb49cc3b", "client", "code='CLEA'")
executeโ
Execute custom/complex statements on your database.
Parametersโ
| Name | Type | Description |
|---|
id | string | Database ID. |
query | string | SQL statement. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.sql.execute('610c0343f6ebc7ddcb49cc3b', "DELETE FROM client WHERE code='KL'")
6 - Instanceโ
launchProcessโ
Initiate an existing process.
Parametersโ
| Name | Type | Description |
|---|
processId | string | Process ID. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.instance.launchProcess('610c0343f6ebc7ddcb49cc3b')
findOneโ
Find one instance that satisfies the specified query criteria.
Parametersโ
| Name | Type | Description |
|---|
query | object | JSON object of criteria to match the instance. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.instance.findOne({ _id: SF.ObjectId('610c0343f6ebc7ddcb49cc3b') })
Find all instances that satisfy the specified query criteria.
Parametersโ
| Name | Type | Description |
|---|
query | object | JSON object of criteria to match instances. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.instance.find({ status: 'running' })
pendingTaskโ
Get Instance latest Pending Task
Parametersโ
| Name | Type | Description |
|---|
instanceId | string | Instance ID. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.instance.pendingTask('610c0343f6ebc7ddcb49cc3b')
getMeasuresโ
Get Instance Measures
Parametersโ
| Name | Type | Description |
|---|
instanceId | string | Instance ID. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
await SF.instance.getMeasures('610c0343f6ebc7ddcb49cc3b')
validateTaskโ
Validate Task.
Parametersโ
| Name | Type | Description |
|---|
taskId | string | Task ID. |
variables | object | JSON of variables. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
let variables = {
"variable1": "value1",
"variable2": 1,
"variable3": true
}
await SF.instance.validateTask('610c0343f6ebc7ddcb49cc3b',variables)
updateVariablesByIdโ
Update variables using instance ID.
Parametersโ
| Name | Type | Description |
|---|
Id | string | Instance ID. |
data | object | JSON of variables data. |
Returnsโ
| Type | Description |
|---|
object | Return object |
Examplesโ
let data = {
"variable1": "value1",
"variable2": 1,
"variable3": true
}
await SF.instance.updateVariablesById('610c0343f6ebc7ddcb49cc3b',data)
attachChildInstanceโ
Is a function that links a child instance to a father instance in the "instances" collection, based on a specific activity step.
Parametersโ
| Name | Type | Description |
|---|
fatherId | string | The ID of the father instance. |
childId | string | The ID of the child instance to be attached. |
stepId | string | The step ID representing the activity in the father instance. |
Returnsโ
| Type | Description |
|---|
Promise<object> | Resolves to { done: true } if the attachment is successful. |
Examplesโ
let result = await SF.utils.attachChildInstance(
"661e9d8a1a2b2f7f8d3c4e1f",
"661e9d9b2b5e2f8f8d3c5f0a",
"step123"
);
getVariablesByIdโ
Is a function that retrieves an instance document by its ID, with an optional projection to select specific fields.
Parametersโ
| Name | Type | Description |
|---|
instanceId | string | The ID of the instance to retrieve. |
projection | object | (Optional) MongoDB projection to specify which fields to return. |
Returnsโ
| Type | Description |
|---|
Promise<object \| null> | Resolves to the instance document if found, or null if not found. |
Examplesโ
let instance = await SF.utils.getVariablesById("661e9d8a1a2b2f7f8d3c4e1f");
let instance = await SF.utils.getVariablesById("661e9d8a1a2b2f7f8d3c4e1f", { variables: 1 });
deleteInstanceByIdโ
Deletes an instance by its ID, and also removes all related histories, tasks, and instancelights associated with that instance.
Parametersโ
| Name | Type | Description |
|---|
id | string | The ID of the instance to be deleted. |
Returnsโ
| Type | Description |
|---|
Promise<object> | Resolves to { done: true } if the deletion is successful. |
Examplesโ
let result = await SF.instance.deleteInstanceById("661e9d8a1a2b2f7f8d3c4e1f");
deleteManyInstancesโ
Deletes multiple instances and instancelights associated with a given process ID and an additional query. This method does NOT delete related tasks and histories for performance reasons.
Parametersโ
| Name | Type | Description |
|---|
processId | string | The ID of the process whose instances should be deleted. |
query | object | Additional query parameters to filter which instances to delete. |
Returnsโ
| Type | Description |
|---|
Promise<object> | Resolves to { done: true } if successful. |
Examplesโ
let result = await SF.instance.deleteManyInstances("661e9d8a1a2b2f7f8d3c4e1f", { status: "completed" });
await SF.instance.deleteManyInstances("661e9d8a1a2b2f7f8d3c4e1f", { createdAt: { $lt: SF.utils.moment().subtract(5, 'days') } })
deleteManyInstancesWithTasksAndHistoriesโ
Deletes multiple instances with all their related data (tasks, histories, and instancelights) associated with a given process ID and query. This is a complete cleanup operation.
Parametersโ
| Name | Type | Description |
|---|
processId | string | The ID of the process whose instances should be deleted. |
query | object | Additional query parameters to filter which instances to delete. |
Returnsโ
| Type | Description |
|---|
Promise<object> | Resolves to { done: true } if successful. |
Examplesโ
let result = await SF.instance.deleteManyInstancesWithTasksAndHistories(
"661e9d8a1a2b2f7f8d3c4e1f",
{ status: "completed" }
);
let result = await SF.instance.deleteManyInstancesWithTasksAndHistories(
"661e9d8a1a2b2f7f8d3c4e1f",
{ createdAt: { $lt: new Date('2024-01-01') } }
);
updateInstanceVariablesโ
Is a function that updates the variables of an instance, recalculates related measures based on the process definition, and updates them both in the instance and the last related task.
Parametersโ
| Name | Type | Description |
|---|
id | string | The ID of the instance to update. |
data | object | Key-value pairs of variables to update inside the instance. |
Returnsโ
| Type | Description |
|---|
Promise<object> | Resolves to { done: true } if the update succeeds. |
Examplesโ
let result = await SF.instance.updateInstanceVariables("661e9d8a1a2b2f7f8d3c4e1f", {
amount: 1500,
dueDate: "2025-05-30"
});
7 - SoftyTableโ
The SoftyTable SDK provides methods to interact with SoftyTable resources, allowing you to perform CRUD operations, execute queries, and manage table data.
The SoftyTable is available as a direct instance on the SF object. All methods take the table ID as the first parameter:
await SF.softyTable.list('tableId123', criteria);
Retrieve rows from a SoftyTable with optional filtering, sorting, and pagination.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
criteria | object | Query criteria with optional where, attributes, include, group, etc. (default: {}) |
limit | number | Maximum number of rows to return (default: 100) |
page | number | Page number for pagination (default: 0) |
sortby | string | Field name to sort by (default: 'createdAt') |
direction | number | Sort direction: 1 for ASC, -1 for DESC (default: 1) |
order | array | Custom order array, e.g., [['field', 'ASC']] (default: null) |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to an array of table rows |
Examplesโ
let rows = await SF.softyTable.list('610c0343f6ebc7ddcb49cc3b');
let activeRows = await SF.softyTable.list(
'610c0343f6ebc7ddcb49cc3b',
{ where: { status: 'active' } },
50,
0,
'createdAt',
-1
);
let rows = await SF.softyTable.list(
'610c0343f6ebc7ddcb49cc3b',
{
where: { age: { $gte: 18 } },
attributes: ['name', 'email', 'age']
},
20,
0
);
Count the number of rows in a SoftyTable with optional filtering.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
criteria | object | Query criteria with optional where clause (default: {}) |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to an object with count property |
Examplesโ
let result = await SF.softyTable.count('610c0343f6ebc7ddcb49cc3b');
let result = await SF.softyTable.count(
'610c0343f6ebc7ddcb49cc3b',
{ where: { status: 'active' } }
);
Create a single row in a SoftyTable.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
data | object | The data object to insert as a row |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to the created row data |
Examplesโ
let newRow = await SF.softyTable.create(
'610c0343f6ebc7ddcb49cc3b',
{
name: 'John Doe',
email: 'john@example.com',
age: 30,
status: 'active'
}
);
createManyโ
Create multiple rows in a SoftyTable at once.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
data | array | Array of data objects to insert |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to an array of created rows |
Examplesโ
let newRows = await SF.softyTable.createMany(
'610c0343f6ebc7ddcb49cc3b',
[
{ 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 }
]
);
retrieveโ
Retrieve a single row from a SoftyTable by its ID.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
rowId | string | The ID of the row |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to the row data |
Examplesโ
let row = await SF.softyTable.retrieve('610c0343f6ebc7ddcb49cc3b', '12345');
Update a single row in a SoftyTable by its ID.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
rowId | string | The ID of the row to update |
data | object | The fields and values to update |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to the updated row |
Examplesโ
let updated = await SF.softyTable.update(
'610c0343f6ebc7ddcb49cc3b',
'12345',
{
status: 'inactive',
updatedAt: new Date()
}
);
updateManyโ
Update multiple rows in a SoftyTable that match specific criteria.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
criteria | object | Query criteria with where clause |
data | object | The fields and values to update |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to update operation result |
Examplesโ
let result = await SF.softyTable.updateMany(
'610c0343f6ebc7ddcb49cc3b',
{ status: 'pending' },
{ status: 'active', processedAt: new Date() }
);
Delete a single row from a SoftyTable by its ID.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
rowId | string | The ID of the row |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to deletion result |
Examplesโ
await SF.softyTable.delete('610c0343f6ebc7ddcb49cc3b', '12345');
deleteManyโ
Delete multiple rows from a SoftyTable that match specific criteria.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
criteria | object | Query criteria with where clause |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to deletion result |
Examplesโ
await SF.softyTable.deleteMany(
'610c0343f6ebc7ddcb49cc3b',
{ status: 'inactive' }
);
await SF.softyTable.deleteMany(
'610c0343f6ebc7ddcb49cc3b',
{ createdAt: { $lt: new Date('2024-01-01') } }
);
Clear all rows from a SoftyTable (delete all data).
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to deletion result |
Examplesโ
await SF.softyTable.clear('610c0343f6ebc7ddcb49cc3b');
getOptionsโ
Retrieve options for select fields in a SoftyTable.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
optionsId | string | The ID of the options field |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to array of options |
Examplesโ
let options = await SF.softyTable.getOptions(
'610c0343f6ebc7ddcb49cc3b',
'status_field'
);
joinTableListโ
List rows from a joined table (many-to-many relationship).
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
joinTableId | string | The ID of the join table field |
criteria | object | Query criteria with optional where clause (default: {}) |
limit | number | Maximum number of rows to return (default: 100) |
page | number | Page number for pagination (default: 0) |
sortby | string | Field name to sort by (default: 'createdAt') |
direction | number | Sort direction: 1 for ASC, -1 for DESC (default: 1) |
order | array | Custom order array (default: null) |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to an array of joined rows |
Examplesโ
let relatedItems = await SF.softyTable.joinTableList(
'610c0343f6ebc7ddcb49cc3b',
'related_products'
);
let items = await SF.softyTable.joinTableList(
'610c0343f6ebc7ddcb49cc3b',
'related_products',
{ where: { category: 'electronics' } },
20,
0,
'price',
-1
);
joinTableCountโ
Count rows from a joined table (many-to-many relationship).
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
joinTableId | string | The ID of the join table field |
criteria | object | Query criteria with optional where clause (default: {}) |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to an object with count |
Examplesโ
let result = await SF.softyTable.joinTableCount(
'610c0343f6ebc7ddcb49cc3b',
'related_products'
);
let result = await SF.softyTable.joinTableCount(
'610c0343f6ebc7ddcb49cc3b',
'related_products',
{ where: { category: 'electronics' } }
);
executeโ
Execute a custom SQL query on the SoftyTable.
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
query | string | The SQL query to execute |
options | object | Query options with replacements and type (default: {}) |
Options Objectโ
| Field | Type | Description |
|---|
replacements | object | Values to replace in parameterized queries |
type | string | Query type: 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RAW', 'SHOWTABLES' |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to the query results |
Examplesโ
let results = await SF.softyTable.execute(
'610c0343f6ebc7ddcb49cc3b',
'SELECT * FROM my_table WHERE status = :status',
{
replacements: { status: 'active' },
type: 'SELECT'
}
);
let results = await SF.softyTable.execute(
'610c0343f6ebc7ddcb49cc3b',
'UPDATE my_table SET status = "processed" WHERE created_at < NOW() - INTERVAL 30 DAY',
{ type: 'UPDATE' }
);
migrateโ
Migrate rows in a SoftyTable (for data migration operations).
Parametersโ
| Name | Type | Description |
|---|
tableId | string | The ID of the SoftyTable |
migrationData | object | Migration configuration data |
Returnsโ
| Type | Description |
|---|
Promise | Resolves to migration result |
Examplesโ
let result = await SF.softyTable.migrate(
'610c0343f6ebc7ddcb49cc3b',
{
}
);
8 - Taskโ
The Task SDK provides methods to interact with task resources, allowing you to query, update, save, and delete tasks.
findOneโ
Find one task that satisfies the specified query criteria.
Parametersโ
| Name | Type | Description |
|---|
query | object | JSON object of criteria to match the task. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.findOne({ _id: ObjectId('610c0343f6ebc7ddcb49cc3b') })
Find all tasks that satisfy the specified query criteria.
Parametersโ
| Name | Type | Description |
|---|
query | object | JSON object of criteria to match tasks. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.find({ status: 'pending' })
deleteTaskByIdโ
Delete a task by its ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | Task ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.deleteTaskById('610c0343f6ebc7ddcb49cc3b')
deleteManyโ
Delete multiple tasks that match the specified query criteria.
Parametersโ
| Name | Type | Description |
|---|
query | object | JSON object of criteria to match tasks. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.deleteMany({ status: 'completed' })
await SF.task.deleteMany({ instanceId: SF.ObjectId('610c0343f6ebc7ddcb49cc3b') })
deleteHistoryByTaskIdโ
Delete all history records associated with a specific task.
Parametersโ
| Name | Type | Description |
|---|
taskId | string | Task ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.deleteHistoryByTaskId('610c0343f6ebc7ddcb49cc3b')
deleteHistoryByInstanceIdโ
Delete all history records associated with a specific instance.
Parametersโ
| Name | Type | Description |
|---|
instanceId | string | Instance ID. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.deleteHistoryByInstanceId('610c0343f6ebc7ddcb49cc3b')
deleteHistoryโ
Delete history records that match the specified query criteria.
Parametersโ
| Name | Type | Description |
|---|
query | object | JSON object of criteria to match histories. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.deleteHistory({ action: 'task_completed' })
await SF.task.deleteHistory({ createdAt: { $lt: new Date('2024-01-01') } })
saveTaskโ
Save a task with updated data.
Parametersโ
| Name | Type | Description |
|---|
taskId | string | Task ID. |
body | object | JSON object with task data. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.saveTask('610c0343f6ebc7ddcb49cc3b', {
status: 'in-progress',
assignee: 'user123'
})
updateTaskโ
Update a task by its ID.
Parametersโ
| Name | Type | Description |
|---|
id | string | Task ID. |
data | object | JSON object of values to update. |
Returnsโ
| Type | Description |
|---|
Promise | Return promise |
Examplesโ
await SF.task.updateTask('610c0343f6ebc7ddcb49cc3b', {
status: 'completed',
completedAt: new Date()
})