Tech Tip: Not supported value error when using Storage.
PRODUCT: 4D | VERSION: 20 | PLATFORM: Win
Published On: April 7, 2025
The Storage method in 4D facilitates data access and sharing in your application. The returned object holds registered data catalogs which are accessible across processes.
While Storage can hold a variety of data types, there are some indications we should follow. Next is a common error developers receive trying to set an array into the Storage object.
Error code: -10721 (4DRT)
Not supported value type in a shared object or a shared collection.
From the documentation of Storage and Shared objects and collection we can note the following elements:
- [...] "Storage is a shared object, it follows the rules described in the Shared objects and shared collections section" [...]
- "Shared objects and collections can only contain scalar values or other shared objects and collections."
The individual elements of an array might be scalar, but not the array itself. Trying to set an array directly in the Storage object might cause the above error.
Here is a correct way to get the values of a text array, and push them to a shared collection inside the Storage object:
Use (Storage) Storage.myData:=New shared object End use ARRAY TEXT($atTestArray; 2) $atTestArray{1}:="Test Value 1" $atTestArray{2}:="Test Value 2" Use (Storage.myData) Storage.myData.arrayValues:=New shared collection ARRAY TO COLLECTION(Storage.myData.arrayValues; $atTestArray) End use |