Skip to main content
Kinetic Community

Looping Through One Column of Customer Answer Table

Overview

Once you have collected answers in a table format and saved them into a JSON as specified in this solution, you will then want to use them. This solution describes how to loop through a column of the stored data to allow for some possibilities on how to process/use these answers.

Usage

What you do with the table stored in the JSON string will entirely depend on what you want to do with it. 

You may want to loop through the rows in the table and perform actions based on each a data point in a column. To do this, you will need to convert the JSON into XML with this handler. Details of constructing a loop in this data are included in the handler page. This same thing can be accomplished, with a little more precision by using the JSON Parse handler to first parse out the desired column, then loop through those results. This gives you the ability to filter out unique values if desired. 

Example

The pictured example is included in the updated Table of Answers service item attached to this solution record. Note that you must load the related/refrenced handlers into your systems before the examples will function. Example trees are inactive. Activate them one at time, activating Loop Through One Column to test this example.

The loop through column example contains three paths. The one on the left uses the Utility JSON to XML handler and uses those results as the datasource of the loop. The example in the middle uses a different technique, using the Utility JSON Parse to pull the desired data out of the json, in this case unique values, and create a new XML of that column, which is used as datasource for the loop. The example on the right uses the Utility JSON Parse to pull the desired data out of the json, in this case all values, and create a new XML of that column, which is used as datasource for the loop. In the third example, the column is integer values that the example finds the maximum of and the sum of.

LoopThroughOneColumn-all.png

Loop Through One Column - Example 1

LoopThroughOneColumn-toXML.png

The loop through column example contains two trees. The one on the left uses the Utility JSON to XML handler and uses those results as the datasource of the loop. The loop path for these answer tables are

//node[@type="Array"]/node[@type="Object"]/node[@name="columnName"]

This example loop just echos the column values to allow you to see the results in the Task Management Console. In practice, you could do anything with the values within the loop.

Loop Through One Column - Example 2

LoopThroughOneColumn-ParseUnique.png

The example on in the middle uses a different technique, using the Utility JSON Parse to pull the desired data out of the json, in this case unique values, and create a new XML of that column, which is used as datasource for the loop. The loop path for this is as specified for the Utility JSON Parse handler.

//items/item

Loop Through One Column - Example 3

LoopThroughOneColumn-ParseAll.png

The example on the right also uses the Utility JSON Parse to pull the desired data out of the json, in this case all values, and create a new XML of that column, which is used as datasource for the loop. The loop path for this is as specified for the Utility JSON Parse handler.

//items/item

The values echoed in this case are processed in two different ways using the techniques listed here. One node finds the maximum of the column.

<%=sum=0
@results['Echo All Quantity'].collect{|key,values| sum = sum + Integer(values['output']) }.inspect
sum%>

Another node finds the sum of all the values of the column.

<%=array = []
   @results['Echo All Quantity'].collect{|key,values| array.push(values['output']) }.inspect
array.max %>

Related

Topics
Dynamic Data Population with Tables
Many times some data is best displayed in a table.  Table data can come from searching a data souce or from a user's input. Learn the methods and tools used to add tables to Service Items and Consoles
Data Viewer JS Library (CE)
Data Viewer is a library which provides a reusable and constant way to build search functionality into a form and display the results. Commonly used behavior is included in the functionality (ie: Set field values in a row or list selection)  Results can be displayed as a Table or List. Custom Renderers may also be created to display search results in an alternate format. The library is configuration driven, reducing the need to create JS when creating simple tables from search results.
Putting Answers into DataTables (CE)
The service item described in this article illustrates (also attached) a simple usage of using a customer's answers to build up a table in Kinetic Request.  This gives the customer to request multiple items (ex. Port details for a Server Add Request) without having to have multiple instances of the same field (ex. Port Type and IP Address) on the service item. The attached example is a very simple application of a clothing order.
Send Customer Answer Table in Email
Email customer an HTML table of answers
Creating List Options based on Table Contents
It may be desired to create list options from a data table in the item.
Making your table scrolling, paginated, or sortable
There are various places within your service item you may be using YUI datatables: to adjust the display of the data returned from a simple data request or a bridging request, to store a table of items your customer is requesting, etc. Occassionally it is desirable to limit the number of records visible or to allow sorting.
Populating a Mobile-Friendly Table Using a Simple Data Request
The service item described in this article illustrates (also attached) a simple usage of Simple Data Request to build up a table in Kinetic Request.  Once loaded, the sample service item uses the Simple Data Request framework to retrieve a list of User records and display a table of Create Date, Modified Date, Email, Login Name, and Full Name field values. When you change the width of the screen small enough to be "tablet" sized, the Email and Create Date columns are collapsed, and when you change the width of the screen to be small enough to be a "phone" the Last Modified column is also collapsed. Collapsed columns can be seen by clicking on the big plus sign that appears in the Full Name column.
Populating a Table Using a Simple Data Request
The service item described in this article illustrates (also attached) a simple usage of Simple Data Request to build up a table in Kinetic Request.  Once loaded, the sample service item uses the Simple Data Request framework to retrieve a list of User records and display a table of Modified Date, Login Name, and Full Name field values.
Populating a Table Using a Simple Data Request with a Row Count
The service item described in this article illustrates (also attached) a simple usage of Simple Data Request to build up a table in Kinetic Request.  Once loaded, the sample service item uses the Simple Data Request framework to retrieve a list of User records and display a table of Modified Date, Login Name, and Full Name field values.
Putting Answers into DataTables
The service item described in this article illustrates (also attached) a simple usage of using a customer's answers to build up a table in Kinetic Request.  This gives the customer to request multiple items (ex. Port details for a Server Add Request) without having to have multiple instances of the same field (ex. Port Type and IP Address) on the service item. The attached example is a very simple application of a clothing order.
Putting Answers into YUI Tables
The service item described in this article illustrates (also attached) a simple usage of using a customer's answers to build up a table in Kinetic Request.  This gives the customer to request multiple items (ex. Port details for a Server Add Request) without having to have multiple instances of the same field (ex. Port Type and IP Address) on the service item. The attached example is a very simple application of a clothing order.
Using a Bridge Search to Populate Questions using a Mobile Friendly Table
This solution describes how to use bridging to do a people search, populating fields on the service item using a bridge request based on criteria the user provides. If there is more than one response to the search, a table is displayed for the user to select the correct individual from. This table uses a mobile friendly version of datatables called FooTables. People Search using Bridges
Using a Bridge Search to Populate Questions using a YUI Table
This solution describes how to use bridging to do a people search, populating fields on the service item using a bridge request based on criteria the user provides. If there is more than one response to the search, a table is displayed for the user to select the correct individual from. This table uses a version of YUI tables. People Search using Bridges
What to do with answers placed in a Table
Once you have collected answers in a table format and saved them into a JSON as specified in this solution, you will then want to use them. This solution describes some possibilities how to process/use these answers.
Loop Through Rows of Customer Answer Table
Once you have collected answers in a table format and saved them into a JSON as specified in this solution, you will then want to use them.  This solution describes how to loop through rows of the stored data to allow for some possibilities on how to process/use these answers.
Looping Through One Column of Customer Answer Table
Once you have collected answers in a table format and saved them into a JSON as specified in this solution, you will then want to use them. This solution describes how to loop through a column of the stored data to allow for some possibilities on how to process/use these answers.
Send Customer Answer Table in Email
Once you have collected answers in a table format and saved them into a JSON as specified in this solution, you will then want to use them. This solution describes how to email the customer answer table.
Storing Customer Answer Table as CSV
Once you have collected answers in a table format and saved them into a JSON as specified in this solution, you will then want to use them. This solution describes how to transform the table to CSV and use that comma delimited result.
Kinetic Table Data Create
Saves the data from a json string created from an HTML table into a Remedy form for future reporting and/or processing. To see how to create the data to feed into this handler, please see the community article here For more information, see the Detailed Description section below.
Kinetic Tabular Data Find
Returns the request ids (field 1) and instance ids (field 179) for all records in the CUSTOM:KS_SRV_TableData_base form that match the provided query. See this page for details on CUSTOM:KS_SRV_TableData_base the form.
Kinetic Tabular Data Retrieve
Retrieves a single CUSTOM:KS_SRV_TableData_base entry with the Instance Id specified. This is equivalent to retrieving a row of data that the customer entered into a table. See this page for details on CUSTOM:KS_SRV_TableData_base the form.
Name Generator
This handler parses a specified path out of a JSON string into XML.
Utility CSV to JSON
This handler converts a CSV string into a JSON string.
Utility Json Parse
This handler parses a specified path out of a JSON string into XML.
Utility JSON to CSV
This handler converts a JSON string into a CSV string.
Utility JSON to HTML
This handler converts a JSON string into an HTML table string.
Utility JSON to Results
This handler converts a JSON string into an XML result string.
Utility JSON to XML
This handler converts a JSON string into an XML string.
Other