Data Structures
The information on this help page applies to both CXone Studio and Desktop Studio.
Data structures allow you to store data to use in your script. You can retrieve the data from the data structure when it's needed, or replace it with other data. In other programming languages, there can be many types of data structures and they can be very complex. In Studio, there are only three types of data structures:
- Variables: A standard variable holds a single value at a time.
- Arrays: An array can hold more than one value. They're useful for storing lists of data that are all the same kind, such as zip codes or the names of ACD skills Used to automate delivery of interactions based on agent skills, abilities, and knowledge. The full array and its contents are stored as a single string.
- Dynamic Objects: A dynamic data object holds more than one value. They're useful for storing data that's all related, such as a contact's name, address, and phone number.
Differences Between Arrays and Objects
Arrays and objects are two kinds of variables. Standard variables hold a single piece of information. If you have a lot of values that are related, you can use arrays or objects instead of multiple standard variables. This allows you to reduce the overall number of variables you use in your script.
Arrays and objects are similar, but there are differences that set them apart. The following table outlines the differences:
String Arrays | Objects |
---|---|
Represent a list of multiple pieces of information. Items in the list are similar in type, but are otherwise unrelated. For example: lists of area codes, customer names, or states. |
Represent "things" in the script, such as contacts, agents, or messages. An object holds information about what it represents. For example: information about a contact, including name, address, and phone number. It's all different kinds of information but it's related by association with the contact. |
A string array holds pipe-delimited strings. The individual pieces of information in the array are called elements. | The pieces of information an objects holds are called members. Members consist of key-value pairs. The key is the name of the member and the value is the actual value it holds. |
The order of the elements within the array, or pipe-delimited string, is important. The script uses the order of elements to keep track of the items in the array. | The order of members within the object is unimportant. |
Elements are identified by a number called an index. You can use the index to iterate through the array and perform an action on each of its elements. In snippets, indexes always start at 1. In some Studio action properties, array indexes start at 0. Always check the online help for the action you're using to determine the starting index. |
Members are identified by their names. Because members don't have numeric identifiers, you cannot perform iterative operations on all of an object's members to update or manipulate them as you can with array elements. To update an object member, you must specify it by name. |
Adding, moving, and deleting elements requires that you know the index of the elements you're moving or deleting, or the index of the elements before or after the element you want to insert, delete, or move. |
To update or add a member to an object, you only need to know the name of it. There's no need to move members because the order of members is unimportant. |