Variables
You can access, update, create and delete app Variables from within your functions.
Create Variables
If you want to create a new Variable, you can use the following code:
const variable = await SUPERFLOW.app.variables.create({
name: 'My variable',
type: 'text',
value: 'Created through my Function',
encrypted: false
})
// Return to see the status of your created variable
return variable
Example output:
{
"created": true // or false if variable could not be created
}
In this example, a new Variable is created with the name My Variable
, the value Created through my Function
, and the type text
. The encrypted
property is set to false
by default, but can be set to true
if you want to encrypt the Variable value.
Update Variables by ID
If you want to update a Variable, you can use the following code:
const variable = await SUPERFLOW.app.variables.update('ffa12345-41b4-46ad-8b64-998c3002c6a0', {
value: 'New value',
// Pass other properties to update if you want
})
// Return to see the status of your updated variable
return variable
Example output:
{
"updated": true // or false if Variable does not exists or could not be updated
}
In this example we updated the Variable with the ID ffa12345-41b4-46ad-8b64-998c3002c6a0
and set its value to New value
.
Update Variables by Name
If you want to update a Variable, you can use the following code:
const variable = await SUPERFLOW.app.variables.updateByName('My Variable', {
value: 'New value',
// Pass other properties to update if you want
})
return variable
// Return to see the status of your updated Variable
Example output:
{
"updated": true // or false if Variable does not exists or could not be updated
}
In this example we updated the Variable with the Name My Variable
and set its value to New value
.
Delete Variables
If you want to delete a Variable, you can use the following code:
const variable = await SUPERFLOW.app.variables.delete('ffa12345-41b4-46ad-8b64-998c3002c6a0') // Pass the variable id to delete it
return variable // Return to see the deleted variable
Example output:
{
"status": true, // or false if Variable does not exists
}
Get Variable by ID
If you want to get a Variable, you can use the following code:
const variable = await SUPERFLOW.app.variables.get('ffa12345-41b4-46ad-8b64-998c3002c6a0') // Pass the variable id to get specific variable
return variable // Return to see the variables
Example output:
{
"id": "ffa12345-41b4-46ad-8b64-998c3002c6a0",
"app_id": "179b58ac-e56a-487b-8735-97a1f531d771",
"name": "My Variable",
"value": "Created through my Function",
"type": "text",
"encrypted": false,
"updated_at": "2024-01-01 11:11:11",
"created_at": "2024-01-01 11:11:11"
}
Get Variable by Name
If you want to get a Variable, you can use the following code:
const variable = await SUPERFLOW.app.variables.getByName('My Variable') // Pass the variable id to get specific variable
return variable // Return to see the variables
Example output:
{
"id": "ffa12345-41b4-46ad-8b64-998c3002c6a0",
"app_id": "179b58ac-e56a-487b-8735-97a1f531d771",
"name": "My Variable",
"value": "Created through my Function",
"type": "text",
"encrypted": false,
"updated_at": "2024-01-01 11:11:11",
"created_at": "2024-01-01 11:11:11"
}
List Variables
If you want to list all Variables, you can use the following code:
const variables = await SUPERFLOW.app.variables.list()
return variables // Return to see the variables
Count Variables
If you want to count Variables, you can use the following code:
const count = await SUPERFLOW.app.variables.count()
return count // Return to see the count
Example output:
{
"total": 34
}
Search Variables
Sometimes you need to search for a specific Variable or a group of Variables, you can use the following code:
const variables = await SUPERFLOW.app.variables.search('My variable') // Search query string that you want to search for
return variables // Return to see the variables
Example output:
[
{
"id": "ffa12345-41b4-46ad-8b64-998c3002c6a0",
"app_id": "179b58ac-e56a-487b-8735-97a1f531d771",
"name": "My Variable",
"value": "Created through my Function",
"type": "text",
"encrypted": false,
"updated_at": "2024-01-01 11:11:11",
"created_at": "2024-01-01 11:11:11"
},
// Other Variables...
]