Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!
The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.
Hello. I have a list of CDT items where each item has an attribute called: "employeeID". I want to split the original array into sub-arrays based on distinct values of employeeID; where each sub-array contains the items corresponding to the employeeID. Is this possible using Appian?
Discussion posts and replies are publicly visible
For something like this, I usually like to separate what you need into distinct steps. The main things that you want to do here are to (1) create a list of distinct values for the employeeID and (2) construct a new list based on these values that matches the original data.
The first step usually involves the union() function. This function allows you to get a unique list of values by defining a union against an empty array.
Then, the second step requires you to loop over the list of values and match the other attributes with the corresponding employeeID. I usually use a combination of wherecontains() and index() to return the corresponding items here. Here's an example with some sample data:
a!localVariables( local!data: { a!map( employeeID: "employee.one", attribute: "abc" ), a!map( employeeID: "employee.one", attribute: "def" ), a!map( employeeID: "employee.two", attribute: "xyz" ), a!map( employeeID: "employee.two", attribute: "123" ), a!map( employeeID: "employee.three", attribute: "abcdef" ) }, local!uniqueEmployees: union( local!data.employeeID, touniformstring({}) ), a!forEach( items: local!uniqueEmployees, expression: a!map( employeeID: fv!item, attributes: index( local!data.attribute, wherecontains( fv!item, local!data.employeeID ), {} ) ) ) )