Skip to main content
Kinetic Community

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.

Usage

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

To be able to loop through all the data in the rows, instead of just one column, by row and a more advanced reporting solution involves saving the data into Remedy and then retreiving the data out. An example of this approach is described in this Create Tabular Data handler page and the cooresponding Find and Retrieve handler pages.

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 Rows to test this example.

Loop Through Rows 

There is one tree with two examples of looping through rows. Both examples use a custom Remedy form (CUSTOM:KS_SRV_TableData_base) and handlers that leverage that form. Note that this example will not work on your system until the form and the handlers are loaded in your system.

Loop Through Rows - All Rows

LoopThroughAllRows.png

The first step is to store the data, then the results of the Kinetic Tabular Data Create node can be used as the data source of the loop head to loop through all the rows. Then the first step within the loop is to retrieve the full row of data. Once the data is returned, anything can be done with it. In this example, there is a simple echo:

<%=@results['retreive row details']['Value4']%> <%=@results['retreive row details']['Value3']%>, <%=@results['retreive row details']['Value2']%> <%=@results['retreive row details']['Value1']%> entered. Comment: <%=@results['retreive row details']['Value5']%>

But you could, in practice, update contact data in the people form, save data to the CMDB, create or update users in AD, add alternate approvers, etc.

Loop Through Rows - Select Rows

LoopThroughPantsRows.png

The other example within the Loop Through Rows tree is very similar, but in this case, since only the rows containing Pants data are desired, a Find must also be done. Then the results of Find are entered in the data source of the loop instead of the results of the Create. This could be used to allow the customer to store both router and server data into the same table, for example, and then  allow these data groups to be processed separately in the tree.