HomeWiki
HomeWiki
  1. Variables
  • Back to home
  • 2. Connectivity
  • Introduction
  • Custom Script
  • Playground
  • Database Explorer
  • Log Stream
  • Direct Communication
  • Softone
    • Getting Started
  • Datapump
    • Getting Started
    • Crons
    • Legacy Windows Support
    • SDK
      • DB
        • _executeQuery
        • _executeStoreProcedure
        • _executeInsertQuery
        • _executeInsertQueriesInTransaction
      • Import
        • _productsImport
        • _categoriesImport
        • _brandsImport
        • _attributesImport
        • _attributeSetsImport
        • _unitsImport
        • _quantityImport
        • _customersImport
        • _contactsImport
        • _callsImport
        • _eventsImport
        • _tasksImport
        • _ordersImport
        • _usersImport
        • _customerSourceTagsImport
        • _productSourceTagsImport
      • Log
        • _logDebug
        • _logInfo
        • _logWarn
        • _logError
      • Web Requests
        • _httpGetJson
        • _httpPostJson
        • _httpPutJson
        • _httpDeleteJson
        • _httpPatchJson
      • Variables
        • _saveVariable
        • _getVariable
        • _deleteVariable
      • Blob
        • _blobConnect
        • _blobExists
        • _blobGet
        • _blobFind
      • Utils
        • _encodeBase64
        • _sleep
        • _getLastSyncDate
        • _updateLastSyncDate
        • _resetLastSyncDate
  1. Variables

_saveVariable

Documentation: _saveVariable Function#

The _saveVariable function is used to store a key-value pair with up to two optional additional values. It facilitates the saving of multiple string values associated with a specific key, which can be retrieved later as needed. The function does not return any value.

Function Signature:#

Parameters:#

key (Required):
Description: The unique identifier under which the values will be stored. This key should be a string and is used to access the stored values later.
Type: string
Example:
value1 (Required):
Description: The primary value to be stored under the specified key. This value must be a string and represents the main piece of data to be saved.
Type: string
Example:
value2 (Optional):
Description: The second value to be stored under the specified key. This value is optional and, if provided, will also be stored alongside value1. It must be a string.
Type: string
Default: undefined
Example:
value3 (Optional):
Description: The third value to be stored under the specified key. This value is optional and, if provided, will be stored alongside value1 and value2. It must be a string.
Type: string
Default: undefined
Example:

Return Value:#

Returns:
This function does not return any value (void).

Function Workflow:#

1.
Validate Parameters:
The function checks if the key and value1 parameters are provided and valid. It ensures that value1 is a non-empty string and that key is a non-empty string.
2.
Store Values:
The function stores value1, and if provided, value2 and value3, under the specified key. All values are stored as strings.
3.
Data Storage:
The function saves the values in a data store or cache, using the key as the identifier. This allows for the values to be retrieved later as needed.
4.
Error Handling:
If any error occurs during the storage process (e.g., invalid key or storage failure), the function may log an error message but does not return any value.

Example Usage:#

Important Considerations:#

Key Uniqueness:
Ensure that the key is unique within the context of your application to avoid overwriting existing data.
String Values:
value1, value2, and value3 must be strings. If you need to store non-string data, consider converting it to a string format before storing.
Data Retrieval:
The function does not handle data retrieval. Ensure that you have a corresponding mechanism to access and use the stored values.
By using _saveVariable, you can store up to three string values associated with a specific key, enabling efficient data management and retrieval within your application.
Previous
_httpPatchJson
Next
_getVariable
Built with