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

_getVariable

Documentation: _getVariable Function#

The _getVariable function retrieves a stored value associated with a specific key. It returns an object containing the details of the stored data, including the key, primary value, and any optional additional values.

Function Signature:#

Parameters:#

key:
Description: The unique identifier used to retrieve the stored values. This key should match the key used when saving the data.
Type: string
Example:

Return Value:#

Returns:
An object containing the details of the stored value associated with the provided key. The object includes:
Id: A unique identifier for the stored item (same as the key).
Key: The key used to store the value.
Value1: The primary value associated with the key.
Value2 (Optional): The second value associated with the key, if any.
Value3 (Optional): The third value associated with the key, if any.
Type: Object
Example:

Function Workflow:#

1.
Retrieve Data:
The function uses the provided key to look up the corresponding data in the storage system.
2.
Construct Result Object:
The function constructs an object with the following properties:
Id: The key used to store the data.
Key: The same as the Id, representing the key.
Value1: The primary value associated with the key.
Value2 (if available): The optional second value associated with the key.
Value3 (if available): The optional third value associated with the key.
3.
Return Object:
The function returns the constructed object, providing all relevant details of the stored data.
4.
Error Handling:
If the key does not exist or an error occurs during retrieval, the function may return an object with default or null values.

Example Usage:#

Important Considerations:#

Key Existence:
Ensure that the provided key exists in the storage system. If the key is not found, the function should return an object with null or default values.
Data Consistency:
The Value1, Value2, and Value3 fields are optional. Ensure that the function can handle cases where these values are not set.
Error Handling:
The function should be robust against errors such as invalid keys or retrieval failures.
By using _getVariable, you can efficiently retrieve stored values associated with a specific key, allowing for easy access to previously saved data.
Previous
_saveVariable
Next
_deleteVariable
Built with