Questionnaires - Best Practice

Last modified on 2022/08/17 10:38

Multi-section questionnaires

From:

  • Service Manager: versions H2.2016 and later
  • Service Apps: versions H1.2017 and later

Using multi-section questionnaires allows you to:

  • Configure the contents of a question based on the answer to a previous question for questions containing SQL code.

example  The first question asks users to select a group while the second asks them to select an employee belonging to the previously selected group.

  • Facilitate the completion of large questionnaires for users.

example  A questionnaire with 70 questions spread over three pages.

  • Ensure that users complete the entire questionnaire before submitting it.

example  A customer satisfaction survey contains 20 optional questions. If these are spread over two pages, this avoids quick answers limited to the first few questions of the survey. 

Configuring questions whose contents depend on previous questions with SQL code

To configure the contents of a question based on the answer to a previous question for questions containing SQL code, the answer to the first question must be saved in the database so that its identifier can be retrieved and used in another question.

  • The first question must be displayed in one section and the second in another section.
  • Once the last question in each section is completed, all of the answers in the section will be saved in the database. Then the next section will be displayed.
    Note: If the last question in the section is an SQL List question, the system will display the next section automatically. Users do not need to click Next.

Notes

  • Only the questions found in the same section will be presented in the display condition of a question. If you want your question to be based on a previous answer in an earlier section, you must use an SQL condition.
  • To configure questions based on previous answers to SQL List questions, you must edit the questionnaire sections in the parent questionnaire. This is the only way in which you can use tags corresponding to answers to previous questions in earlier sections in a multi-section questionnaire.

Procedure

       Example: Questions based on answers to previous SQL List questions

1. Create the different sections you want.

  Note: Do not configure the conditions that will be based on previous SQL List questions.

2. Create the multi-section questionnaire and associate the sections.

3. Edit the section containing a question whose contents are based on a previous answer. Add the code of the previous question using the Roles-Tags window icon.png icon.

         Question_code tag.png

4. Check that the display conditions of the original questionnaire do not refer to questions that have been moved to different pages. Open url.png See the query in the FAQ.

Best Practice

  • When the last question of a section is an SQL List question, the next section will automatically appear once this question is completed. To remove the need for users to click Next button to go on to the next section, you should try to place this type of question at the end of the section.
  • Enter a unique and meaningful code for all multi-section questions that are referenced in the display conditions of other questions because this code will be used as a key in the condition.
  • When the contents of a question depend on the answer to an SQL List question, remember to design your questionnaire so as to take into account situations where there may be no answer given.

example   List of incidents for a given asset

Best Practice Not recommended
SD_REQUEST.ASSET_ID=cast('#[QUESTION_CODE.ASSET]#' as integer)
  • The cast function replaces null values with a zero, e.g. if no equipment was selected.
  • The query will not return any result.
SD_REQUEST.ASSET_ID=#[QUESTION_CODE.ASSET]#
  • If no equipment was selected, the query displays an error message when users select an incident.
  • In certain cases, we recommend that you display a question whose contents depend on a previous answer to an SQL List question only if the previous question was completed.

example  Questions for selecting a department by level

  • The Department level L+1 question should only be displayed if the Department level L question was completed.
  • In this case, as the questions must be placed in different sections, you must use the SQL display condition.
            Open url.png  See Display condition based on a question in a previous section.

Display condition based on a question in a previous section

If you are unable to group a question and its corresponding conditional question within a given section, then you must use the SQL display condition.

example  For a checkbox condition:

  • Table
SD_REQUEST
  • Joins
INNER JOIN SD_QUESTION_RESULT ON SD_QUESTION_RESULT.REQUEST_ID = SD_REQUEST.REQUEST_ID
INNER JOIN SD_QUESTION ON SD_QUESTION_RESULT.QUESTION_ID=SD_QUESTION.QUESTION_ID AND SD_QUESTION.QUESTION_CODE='QuestionCode' AND SD_QUESTION_RESULT.RESULT_BIT = 1
  • Condition (WHERE)
SD_REQUEST.REQUEST_ID=@ID@
  • To take into account multi-cart cases, you should add a second condition using the OR operator and replace the previous joins with the ones below:
INNER JOIN SD_REQUEST_DETAIL ON SD_REQUEST_DETAIL.REQUEST_ID = SD_REQUEST.REQUEST_ID
INNER JOIN SD_QUESTION_RESULT_DETAIL ON SD_QUESTION_RESULT_DETAIL.REQUEST_DETAIL_ID=SD_REQUEST_DETAIL.REQUEST_DETAIL_ID
INNER JOIN SD_QUESTION QUEST_DETAIL ON
SD_QUESTION_RESULT_DETAIL.QUESTION_ID=QUEST_DETAIL.QUESTION_ID AND QUEST_DETAIL.QUESTION_CODE='QuestionCode' AND SD_QUESTION_RESULT_DETAIL.RESULT_BIT = 1

Notes

  • SQL List questions based on answers to previous questions (using a #QUESTION_CODE.xxx# tag) cannot be tested in preview mode. An error will appear if you try to open the list.
  • The override functionality in questionnaires will no longer be available for sections.
  • The space for displaying text is reduced in sections/pages.
    • When you divide a questionnaire into sections/pages, you should shorten long text to avoid displaying it over several rows.
    • To increase the space available for displaying text, you can add the following override to the customer_optimized.css file:
.question_label {    white-space: nowrap;  }

Procedure: How to change a long questionnaire to a multi-section questionnaire

ProcedureChangeTypeQuestionnaire

Step 1: Analyze of the questionnaire.

1. Decide how many pages the questionnaire should be divided into.

2. Determine the questions to be placed at the start and end of each page.

Note: The display condition of a question based on a previous answer in an earlier page must be expressed again as an SQL condition. 

Best Practice icon.png  

  • To save time and facilitate the expression of these SQL conditions, you should group, on the same page, questions whose answers determine the display of other questions and these conditional questions. 
  • If the questions cannot be grouped, edit the display conditions to change them to SQL.
    Open url.png  See the example of a query.

3. Note down the display order value of the first and last questions of each page.
 

Step 2: Creation of the questionnaire sections.

1. Duplicate the questionnaire as many times as required to create the pages in your questionnaire. Check the Is a section box each time.

2. Edit each of the questionnaire sections you just created.

3. Delete the questions found in the other sections (pages).

Note: In large questionnaires, it may take some time to delete a question. You can delete questions quickly by running a query in the database.
Caution: You should test the query first in the sandbox environment because it involves the deletion of data.

  • Edit each of the questionnaire sections and take note of the identifier displayed in the URL to the right of the q2_id parameter:

    example   ...filter=1&q2_id=68&q2_tree_id=...

  • Run the query below.
DELETE FROM sd_question_question_list
WHERE  question_list_id = parameterValue
      AND ( display_order < firstQuestionOrderValue
      OR display_order > lastQuestionOrderValue );

Step 3: Creation of the multi-section questionnaire.

1. Create the multi-section questionnaire.

2. Associate the questionnaire sections. Check the New page box for each section.

3. Check that the display conditions of the original questionnaire do not refer to questions that have been moved to different pages.

    Open url.png See the query in the FAQ.
 

Step 4: Use of the new questionnaire in the processes.

1.  Replace the old questionnaire with the new multi-section questionnaire in workflows and questionnaire overrides.

EndProcedureChangeTypeQuestionnaire

Survey questions

From:

  • Service Manager: versions H2.2016 and later
  • Service Apps: versions H1.2017 and later

You define the display of survey questions by adding a table header question followed by a series of radio button questions with the same choice of answers. No labels should be displayed (Display item label = False).

              Exemple: Survey questionnaire

  • To ensure that radio buttons are correctly aligned, you should specify the same number of options in each row (up to 11) for each question in the series. You should also define the same alignment, i.e. left, center or right.
  • The space reserved for displaying the radio button answers is divided into 12 columns.
    • Depending on the number of answers to a question, each radio button will be displayed in a space whose width will vary from one to six columns.
    • If your question has seven answers, the seven radio buttons will be displayed in the same way as a question with 11 options. This means that there will be one radio button in each column.
Number of options Number of columns for displaying a radio button
2 6
3 4
4 3
5,6 2
7 à 11 1
  • To align radio buttons for two series of questions with different numbers of options, you can proceed as follows for the series with fewer options:
    • Add empty elements in the table header so as to have the same number of elements as the other series of questions.
    • Specify the same value in the Number of Elements in a Row parameter as in the other series of questions.

Best Practice

  • Select the Center alignment for the text in the table header and for the radio buttons.
  • If the text in the table header is too long, insert a line break by adding the <BR /> tag to prevent truncation.

example

Labels on two rows Labels on one row
Labels on two rows.png Labels on one row.png

Configuring target fields

From: Service Manager: versions 2015 and later

Using target fiels allows you to save answers in the SD_REQUEST table fields. This is especially useful for Portal apps in which users can create an incident or service request. This functionality enables you to specify the equipment, location and other fields.

Question specific to Service Apps

  • Configure the questionnaire so that questions with target fields are displayed only when the incident/request is created in Service Apps, by selecting the Apps Only option.
  • Caution: If you use the SD_CATALOG_ID field (catalog category) as the target field, the value will not be recalculated by the system (target resolution date, SLA, workflow, etc.).

Best Practice icon.png  You should pay special attention to mandatory fields in the quick call, such as location or urgency. If you add them to the questionnaire, you should ensure that the questions are defined as mandatory. If this is not the case, then default values will be deleted in the database, thus preventing the workflow from starting correctly.

Consistency with other updated sources of data

  • Ensure consistency with other updated sources of data.
  • Identify business rules and internal update steps that can modify destination fields used in questionnaires.
  • Check for global consistency.

Checking target fields

  • Check that target fields are not updated by theme wizards
  • System fields such as RFC_NUMBER or REQUEST_ID are protected and cannot be specified as the target.
  • Certain fields are updated in a specific context.

example   The REQUESTOR_PHONE field is found in the transfer wizard for change requests. However, it can also be used as the target in an incident process questionnaire.

List of fields to avoid as targets depending on context

Note: Except for Apps Only questions

  • Incident:
    • EXPECTED_START_DATE_UT
    • EXPECTED_END_DATE_UT
    • DESCRIPTION
  • Change request:
    • REQUESTOR_PHONE
  • Multi-cart change request:
    • CI_ID

Formatting questions

Questions containing HTML code

From Service Manager version H1.2016 onwards, you can define the layout using the WYSIWYG editor available for the Description field in questions.

You should limit complex formatting (e.g. tables, images, etc.) to Comment type questions.

Comment questions

You can ask users to add details, recommendations and comments using Comment questions. No data entry field is added. 

Note: These questions will be displayed over the entire width of the questionnaire.

FAQ

From version H2.2016 onwards, labels in questions are aligned by default to the right. If you want to align them to the left, you should add the following override to the customer_optimized.css file:

.question_label {    text-align: left; }

After splitting the questionnaire, display conditions based on questions that have been moved to another section must again be configured as an SQL condition. Open url.png See the description.

Run the query below to identify the questions whose display conditions must be reconfigured:

SELECT q.question_id as 'Question (ID)',q.question_en 'Question',questCondition.QUESTION_LIST_ID 'Questionnaire (ID)',
qlist.QUESTION_LIST_EN 'Questionnaire',questCondition.QUESTION_ID 'Question to be reconfigured (ID)' ,
qConditionned.QUESTION_EN 'Question to be reconfigured'
FROM sd_question q
INNER JOIN ( SELECT T.C.value('.','nvarchar(max)') as guid,A.*
FROM
(
SELECT T.C.query('.') as XML,A.*
FROM (SELECT QUESTION_ID,QUESTION_LIST_ID,DISPLAY_ORDER,cast(CONDITION as xml) CONDITIONs FROM SD_QUESTION_QUESTION_LIST
) A
CROSS APPLY CONDITIONs.nodes('/conditions/condition') T(C)
) A
CROSS APPLY XML.nodes('/condition/guid') T(C) )  questCondition on questCondition.GUID=q.QUESTION_GUID
INNER JOIN SD_QUESTION_LIST qlist on qlist.QUESTION_LIST_ID=questCondition.QUESTION_LIST_ID
INNER JOIN SD_QUESTION qConditionned on qConditionned.QUESTION_ID=questCondition.QUESTION_ID
WHERE NOT EXISTS (SELECT 1 FROM SD_QUESTION_QUESTION_LIST qql where qql.QUESTION_LIST_ID=questCondition.QUESTION_LIST_ID AND qql.QUESTION_ID=q.QUESTION_ID)
Tags:
Powered by XWiki © EasyVista 2022