ListPersistentDataIDs

Returns a list of instance IDs for the entries with the specified name in the persistent data store.

Format 

ListPersistentDataIDs ( name )

Parameters 

name - a text expression that specifies the name of an entry to search for.

Data type returned 

text

Originated in version 

26.0

Description 

The carriage-return-delimited list of instance IDs returned by this function is useful for discovering what instances exist for a given name. See About the persistent data store for more information.

If no entries exist with the specified name, this function returns an empty value.

Notes 

  • Instance IDs are returned in the order the entries were created.

  • If a matching entry was stored with an empty instance ID, an empty value is included in the list.

  • Use with GetPersistentData function to retrieve values for each instance.

Example 1 

ListPersistentDataIDs ( "com.example.addon.script" ) lists all instance IDs for entries that have this name. For example:

Copy
38EA3124-9CFD-4490-A634-A0A72A613145
E53DE16C-282E-44B0-BDB8-D59B15419D1B

B2F4C8D1-5A3E-4F9B-8C7D-1E6A9B4D2F5C

Four instance IDs are returned, but the third line is blank because that entry has an empty instance ID.

Example 2 

For a given entry name, returns a JSON array containing an object for each instance ID. Each object includes the name, instance ID, and value of the matching entries.

Copy
Set Variable [ $entryName ; Value: "com.claris.myaddon.theme" ]
Set Variable [ $entryArray ; Value: "[]" ]
Set Variable [ $i ; Value: 1 ]

Set Variable [ $instanceIDList ; Value: ListPersistentDataIDs ( $entryName ) ]

Set Variable [ $totalInstances ; Value: ValueCount ( $instanceIDList ) ]

Loop [ Flush: Always ]
  Exit Loop If [ $i > $totalInstances ]
  
  Set Variable [ $currentInstanceID ; Value: GetValue ( $instanceIDList ; $i ) ]
  Set Variable [ $entryValue ; Value: GetPersistentData ( $entryName ; $currentInstanceID ) ]
  
  Set Variable [ $entryObject ; Value: "{}" ]
  Set Variable [ $entryObject ; Value: JSONSetElement ( $entryObject ; "name" ; $entryName ; JSONString ) ]
  Set Variable [ $entryObject ; Value: JSONSetElement ( $entryObject ; "instanceID" ; $currentInstanceID ; JSONString ) ]
  Set Variable [ $entryObject ; Value: JSONSetElement ( $entryObject ; "value" ; $entryValue ; JSONString ) ]
  
  Set Variable [ $entryArray ; Value: JSONSetElement ( $entryArray ; "[+]" ; $entryObject ; JSONObject ) ]
  
  Set Variable [ $i ; Value: $i + 1 ]
End Loop

Show Custom Dialog [ JSONFormatElements ( $entryArray ) ]

Example of the resulting array:

Copy
[
  {
    "instanceID" : "38EA3124-9CFD-4490-A634-A0A72A613145",
    "name" : "com.claris.myaddon.theme",
    "value" : "Dark"
  },
  {
    "instanceID" : "E53DE16C-282E-44B0-BDB8-D59B15419D1B",
    "name" : "com.claris.myaddon.theme",
    "value" : "Dark"
  },
  {
    "instanceID" : "",
    "name" : "com.claris.myaddon.theme",
    "value" : "Light"
  },
  {
    "instanceID" : "B2F4C8D1-5A3E-4F9B-8C7D-1E6A9B4D2F5C",
    "name" : "com.claris.myaddon.theme",
    "value" : "Dark"
  }
]