Reporting and Analytics for Service

Get Involved. Join the Conversation.

Topic

    Bastiaan van der Kooij
    Search in Answer Source (Using Custom Script) -...
    Topic posted April 28, 2016 by Bastiaan van der Kooij Gold Crown: 30,000+ Points, last edited September 29, 2017 
    738 Views, 4 Comments
    Title:
    Search in Answer Source (Using Custom Script) - Analytics Cookbook Recipe
    Content:



    Search in Answer Source



    Using a custom script



    Author: Bastiaan van der Kooij

    Independent Oracle Service Cloud Consultant



    Difficulty rating:   (Advanced)



    Target persona: Knowledge Base Manager



    Ingredients:



    8 Columns  (4 are hidden and used for the custom script)



    2 Variables



    2 Conditional formats



    1 Custom Script



    Overall description/purpose: Using the standard Analytics capabilities, it is not possible to search within the actual HTML source of answers, therefore making it very difficult to search for links and other html entities. This report uses a custom script to overcome this lack of functionality. It shows the answers when a match is found and indicates using a checkmark whether it was found in the question or in the answer. In the filter section a user can enter their search phrase and indicate if they want to search in the answer, the question or both.



    Screen shot:





    NOTE: Data returned in the above report is intentionally blurred. These are answer IDs and Summary for answers.



    Master Chef Approved (a.k.a. Data Validated)? Yes



    Report Configuration Details



    The following section is intended to detail specific areas of the report that are not well described by the PDF report definition.




    1. Tables, columns, and filters definitions are shown in the PDF definition. 



      a.   In essence the script in the Process tab is executed for each row. It reads the search phrase & type and checks if there is a match in the source of the answer. If there is it adds a 1 to the Found in Question / Found in Answer column based on the result and continues to the next row. When there is no match it removes the row > $rows = array();



      b.   The code in the Headers section is not essential for the functionality of a custom script but is something that can be considered ‘good practice’. This section prevents the report from failing when users change the order of columns or add new columns since it picks up the columns by name. So the drawback from this is you cannot easily change the name of the column, without changing the script as well; up to you… It works by searching the columns in the headers section by its name and storing the column number in a global variable. This variable is picked up in the process tab and used to identify the correct column.



    2. Custom Script



      NOTE: Be sure to select “No” during the custom script prompt that occurs during the report import process. This custom script is necessary for this report to function properly.



      Since this is not a PHP lesson the script is functionally described:



      a. In essence the script in the Process tab is executed for each row. It reads the search phrase & type and checks if there is a match in the source of the answer. If there is it adds a 1 to the Found in Question / Found in Answer column based on the result and continues to the next row. When there is no match it removes the row > $rows = array();



      b. The code in the Headers section is not essential for the functionality of a custom script but is something that can be considered ‘good practice’. This section prevents the report from failing when users change the order of columns or add new columns since it picks up the columns by name. So the drawback from this is you cannot easily change the name of the column, without changing the script as well; up to you… It works by searching the columns in the headers section by its name and storing the column number in a global variable. This variable is picked up in the process tab and used to identify the correct column.




    Included are the following (in a .ZIP file):



    • Human readable PDF report definition
    • XML Report definition 
    • Screen shot 


    Comment

     

    • Erica (Leep) Anderson

      We are experimenting with leaving these report recipe posts open for comments, because we want report chefs to hear how their report recipes helped you. If you found this report recipe helpful, please give Bastiaan's post a thumbs up and leave a comment letting him know you appreciate his help, how this report helped you and your organization, etc.

      If you have a question about this report recipe, please start a new topic in the "Reporting and Analysis" forum board and link to this report recipe in your question. DO NOT post your reporting question here. We will remove any comments asking for help in the comments of this post.

      Thanks,
      Erica, Community Manager

    • Geetha Amrutha

      Thanks Bastiaan.

      I was looking for this solution and wondering how to filter use the Answer keywords in the report filters. This has helped.

      Regards,
      Geetha

    • Mark Kehoe

      Good work Bastiaan! I'm going to enjoy getting inside what you've done yes

    • CorineMc

      Bastiaan,

      I have to tell you I have used this report countless times!  Thank you SO much!  For instance I have used it to find answers with Conditional Sections, answers with certain images, answers with links to videos, the list goes on an on.

      I cannot thank you enough for sharing this!

      Your Groupie,
      Corine