GetKeySets

Retrieves Keys values in GroupName for keysets that match Condition.

When an asterisk * is passed as the Keys parameter, all keys are retrieved.
To ensure backward compatibility with versions prior to 2018.1, all keys are retrieved when the Keys parameter is left empty. It is however recommended to use an asterisk instead.

When Condition is left empty, all keysets are retrieved, which is useful for reports, cleanup, or custom filters based on more complex conditions.

GetKeySets() converts the results coming from the Repository from UTF8 to Ansi, in order to make results with special characters like 'éèêë?æ' compatible with scripting.
To obtain the UTF8 value, without conversion, use GetKeySetsW().

Syntax​

GetKeySets(GroupName: string, Keys: JSONStringArray, Condition: string): JSONStringArray

Examples

Basic examples

In each of these examples, the object repoObject is deemed having been obtained through a call to the COM object "RepositoryLib.WorkflowRepository" (see Obtaining an instance of the Repository Object).

JavaScript​

repoObject.GetKeySets("Users", '["FirstName","LastName"]', "Gender='M'");

VB Script​​​

myKeySet = repoObject.GetKeySets("Users", "[""FirstName"",""LastName""]", "Gender='M'")
Querying a single row

This JavaScript example shows how to get one or more rows from the repository and use them in the process. The script gets 3 fields ("firstname", "lastname" and "email") from the CustomerID field. It assumes there's a local variable called %{CustomerID} set in the workflow process.

var CustomerID = Watch.GetVariable("CustomerID");
var repoObject = new ActiveXObject("RepositoryLib.WorkflowRepository");
var customer = repoObject.GetKeySets("customers",'["firstname","lastname", "customerID"]',"customerID = '" + CustomerID + "'");
Watch.SetJobInfo(9,customer);

By replacing the last option from GetKeySets (the filter on CustomerID) with an asterisk, you can get all the rows from the data repository.

Return value: JSONStringArray

The method returns a JSONStringArray of key-value pairs, for example:

'[{"FirstName": "John","LastName": "Smith"},{"FirstName": "Richard", "LastName": "Doe"}]'

The return value (saved for example in the %9 JobInfo variable, as the above example does) can be used in a number of ways:

  • It can be returned to a web page that's making an HTTP request to Workflow. JSON is the simplest way to transfer information between any system that supports JavaScript.
  • It can be passed to Designer and loaded up directly as an object in a script there.
  • The JSON can be converted to XML, which makes it useable in the DataMapper module. This can be easily done in a preprocessor script in the DataMapper (see DataMapper online help).