Skip to main content
Kinetic Community

Data Pull

This package contains the files necessary for displaying results from Kinetic fulfillment records (approval, work order) in the customer's review request. This allows the customer to view fulfillment information without creating duplicates of all the fulfillment answer in the original request.

Installation / Quick Start

This code assumes the following:
  • The Work Order Name is stored in Attribute11. This is the case of the Handlers available here.
  • A bundle is being used for the theme. Non-Bundle theme use will require modifications to the paths of includes and callback calls.
  1. Unzip the DataPullModels.zip contents in your bundle in /packages/base/framework/models/

  2. Unzip the DataPullCallbacks.zip contents in your bundle in /packages/base/interface/callbacks/

  3. Place dataPull.js in your bundle in /packages/base/resources/js/
    OR
    Copy the contents of dataPull.js into display.js (in the same location)

    If you are going to be using this feature frequently, it would be advised to include the necessary js in a file that is automatically loaded into all service items, so the functions are always available.

  4. Place dataPull.css in your bundle in /packages/base/resources/css/
    OR
    Copy the contents of dataPull.css into display.css (in the same location)

    If you are going to be using this feature frequently, it would be advised to include the necessary styles in a file that is automatically loaded into all service items, so the styles are always available.

  5. If the dataPull.js and dataPull.css are not included in the display files and need to be called explicitly, add the following to the Customer Header Content of your Service Item:
    <script type="text/javascript" src="kinetic/themes/<yourbundle>/packages/base/resources/js/dataPull.js"></script>
    <link rel="stylesheet" type="text/css" href="kinetic/themes/<yourbundle>/packages/base/resources/css/dataPull.css">
    
    Note that you will need to replace the <yourbundle> text with the name of your bundle/theme.
  6. Follow the following instructions for whatever data you wish to pull into your Service Item. You can do any combination of these such as pulling all visible answers from one work order, but only a specific question from another. 

All Visible Work Order Answers

To get the non-removed or hidden answers for a given work order, create a div tag on your service where you want the question/answer pairs to appear that looks like this:

<div id=workOrderAnswers></div>

Example:
workOrderAnswersDiv.png

It must have this id. Then create an event on page load (for review mode) that does this:

loadWorkOrderAnswers(KD.utils.ClientManager.customerSurveyId,'PC Build');

Where I have 'PC Build', you would want to include the name of your work order, ex 'My Work Order'.

Example:

workOrderAnswers.png

All Answers for a Submit Type (Work Order or Approval)

To get the answers for all work orders (or approvals), create a div tag on your service where you want the question/answer pairs to appear that looks like this:

<div id="fulfillmentAnswers"></div>

Example:
AnswersForAllWorkOrdersDiv.png

It must have this id. Then create an event on page load (for review mode) that does this:

loadTypeAnswers(KD.utils.ClientManager.customerSurveyId,'WorkOrder');

Where I have 'WorkOrder', you could instead include 'Approval'. That would get you all the not removed/hidden answers for all approvals instead of all work orders.

Example:

AnswersForAllWorkOrders.png

A Specific Work Order Answer

To get the answer for a given question on a specific work order, create a div tag on your service where you want the question/answer pair to appear that looks like this:

<div id="PCTagNumber"></div>

Example:
SpecificWorkOrderAnswerDiv.png

Where the id of the div is the question name with any spaces removed. Remember that if you are pulling back more than one answer, you can use the same text element for all the necessary divs if desired.

Then create an event on page load (for review mode) that does this:

loadWorkOrderAnswer(KD.utils.ClientManager.customerSurveyId,'PC Build', 'PC Tag Number');

Where I have 'PC Build', you would want the name of your work order, and where I have 'PC Tag Number', you would want the label of the question you want to retrieve.

Example:

SpecificWorkOrderAnswer.png

Display a Specific Table Work Order Answer

To get the answer for a question that has a tables JSON string in it so you can display that table in your service item, you want to
1) Create a question on your service item to recieve this JSON (you probable want this removed/hidden)
2) Create a div tag on your service item where you want the table to appear that looks like this:

   <div id="selectedAccessoriesTable"></div>

Example:
TableQuestionAnswerDiv.png
    Where the id in the div is what your build table function will be looking for (see example below)
3) Add the build table function for the json string into your service items Custom Header Content (see example below)
4) On Page load have an event like this to go get the question from the work order and place it in the question you created:

putWorkOrderAnswerIntoQuestion(KD.utils.ClientManager.customerSurveyId,'Hardware Accessories Deployment','_StoredAccessoriesTableData','_StoredAccessoriesTable');

      Where there is 'Hardware Accessories Deployment' you should have the name of your work order, the next item is the question label of the question your are retrieving the data from, and the last is the question you have created in step 1 that you are putting the data into.
Example:
TableQuestionAnswer.png

5) Then create an event on change of the json question on your service item that builds the table and resets the review size like this:

buildAccessoriesTable('_StoredAccessoriesTable');
setTimeout('KD.utils.Review.setHeight();',1000);

Example:
TableChangeEvent.png

  Note that your build table function name and the name of the question you pass it will likely be different. It's also important to note that if your table is displayed in the work order as part of a "two-table" arrangement, you'll need to write a separate build table function (not use two-tables here).  When using a build for a two-tables table, you need to add a [ and ] around the json string returned for it to parse properly.  Here is an example of such a function. The line that would not be necessary if it was not originally a two-table is in blue.

function buildAccessoriesTable(jsonDataQuestion) {
    var oTxt = KD.utils.Action.getQuestionValue(jsonDataQuestion);
    if (oTxt.length == 0) {
        var myDataSource = new YAHOO.util.DataSource([]);
    } else {
       oTxt = "["+oTxt+"]";
        var myDataSource = new YAHOO.util.DataSource(YAHOO.lang.JSON.parse(oTxt));
    }
    myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
       
        myDataSource.responseSchema = {
      fields: [
        { key: "requestid" },
        { key: "description" },
                { key: "cost" },
                { key: "manufacturer" },
                { key: "name" },
                { key: "image" },
                { key: "quantity" },
                { key: "license" }
      ]
    };
  // CONFIGURE: The following variable defines which element the YUI data table
  //   will be inserted into and will need to be set to an element that exists
  //   in the service item.
  var containerElement = "selectedAccessoriesTable";

  // CONFIGURE: The following variable defines what columns will be displayed in
  //   the table and will need to be configured for the specific Simple Data
  //   Response.
 
  var myColumnDefs = [
        { key: "requestid", label:"Request", hidden: true },
        { key: "description", label:"description",hidden: true },
                { key: "name", label:"Name"},
                { key: "manufacturer", label:"Manufacturer" },
                { key: "cost", label:"Price" },
                { key: "image",label:"image", hidden: true },
                { key: "quantity", label:"Quantity" },
                { key: "license",label:"license", hidden: true }
  ];

  // Build the data table widget
  tableAccessories = new YAHOO.widget.DataTable(containerElement, myColumnDefs, myDataSource);
         tableAccessories.subscribe("rowMouseoverEvent", tableAccessories.onEventHighlightRow);
        tableAccessories.subscribe("rowMouseoutEvent", tableAccessories.onEventUnhighlightRow);
        tableAccessories.subscribe("rowClickEvent", tableAccessories.onEventSelectRow);

}

Display Fulfillment Anwer in Place of Customer Answer

It may be desired to override what is displayed to a customer in the same Answer they entered the data in. This data pull will replace what is used for display only; it will not replace what is actually stored in the Service Item Request. 

In a Custom Load event to go get the answer from the work order and place it in the question:

putWorkOrderAnswerIntoQuestion(KD.utils.ClientManager.customerSurveyId,'PC Deployment','Confirmed Deployment Date','Scheduled Deployment Date');

Example:

AnswerIntoQuestion.png

Because the data is being placed in an existing question, no additional div or question is needed.

Display Location

As indicated in the previous sections, certain div tags (in Text elements) will needed to be added to the Service Item. Note that if you want these fulfillment answers to display on a separate page that doesn't appear until there is fulfillment data to view, there is one additional step. When there is data to pull, you will need to use a create answers handler to create an answer in a hidden or removed question on the fulfillment answers page. This is necessary because a page without answers will not display in a Review Request.

Styling / Customization

The following css designations are available for styling the results in the page. A sample css was provided, but it will likely need to be modified to fit your themes' styles.

 

CSS Designation Description
Div classes
.QuestionAnswerDetails The outer div class for each record set
.info If a submit type is being used, it is listed as a sort of header for the answers below, this is the outer div classed used for this information.
.serviceItem If a submit type is being used, it is listed as a sort of header for the answers below, this is the outer div classed used for this information.
.answers The div class that contains all the requested answers
.answer The div class that contains one specific answer
.label The div class for the label for one specific answer
.value The div class containg the value of one specific answer
.clear A div tag used to clear desired floats