Creating a survey questionnaire
To create a survey questionnaire in PWA, perform the following tasks:
Before you begin
Make sure you have a basic understanding of the following:
- Defining-workflow-to-automate-processes
- Defining-Set-Fields-actions-to-assign-values-based-on-conditions
- Defining-Run-Process-actions-to-run-processes-programs-or-commands
- Enabling Progressive Views for forms from the Centralized Configuration
Task 1: Add a survey component definition in Developer Studio
Add a survey component definition in Developer Studio, which contains the mappings for the following system forms in Action Request System and a qualification. Based on this qualification, the questions and options are shown in the questionnaire.
Form | Purpose |
---|---|
Question | The questions data is loaded from this form. |
Options | The options for the selected questions are loaded from this form. |
Response | The responses to the questions are stored in this form. |
Action Request System contains a system form called Survey Component Definition. An administrator can configure the Question form information, Option form information, and Response form information on this form. To configure all this information, the administrator must create a record on the Survey Component Definition form, from where all the questions, options, and responses are fetched. This record is displayed as a value in a list for the Component Definition property in Developer Studio.
For example, you can create the following entities:
- A record called Survey Questionnaire
- Three custom forms, namely Survey_Question, Survey_Option, and Survey_Response
- General fields, such as Question ID, Parent Entity ID, Question Label, Locale, and Company
To add a survey component definition:
- On a form in progressive view, drag the Survey Component field.
- On the Properties pane, expand the Display property group.
- Click the Component Definition property.
- In the Value column, select the record that you have already created.
Task 2: Add a qualification with a qualification field ID
A qualification field ID is an ID on the form where your survey is available. Based on the qualification that you select during runtime, the questions and options for the survey questionnaire are displayed in PWA. You can specify a qualification at runtime or you can hard code it while creating your survey questionnaire.
To add a qualification:
- In the Properties pane, click the Qualification Field ID property.
- In the Value column, click the ellipsis (
) button.
- In the Qualification Field ID dialog box, select the required field.
- Click OK.
Task 3: Add a parent entity ID
The parent entity ID is used for edit and view purpose, to display the records in the View or Edit mode. The Parent Entity ID field holds the value of a record ID. Based on this record ID, the records that are to be displayed on the UI are fetched.
For example, in the View mode, the records are displayed as follows:
In the Edit mode, the records are displayed as follows:
To add a parent entity ID:
- In the Properties pane, click the Parent Entity ID property.
- In the Value column, click the ellipsis (
) button.
- In the Parent Entity ID dialog box, select a field that is a record ID.
- Click OK.
Task 4: Enable displaying a survey in View mode
To show a survey questionnaire in the View mode, set the value for the Display As Text property to True. Only when this property is set to True, the Question Font and Answer Font properties are enabled in Developer Studio.
For example, the following image shows a survey questionnaire in the View mode:
To enable displaying a survey in the View mode:
- On the Properties pane, click the Display As Text property.
- In the Value column, select True from the list.
Task 5: Set the fonts for questions and answers
- In the Properties pane, expand the Font property group.
- Click the Question Font property.
- In the Value column, select a value from the list.
- Click the Answer Font property.
- In the Value column, select a font from the list.
Task 6: Set the run process to fetch survey data
PERFORM-ACTION-FETCH-SURVEY-DATA run process
To fetch the survey data, use a run process called PERFORM-ACTION-FETCH-SURVEY-DATA on the survey component. Based on the component ID and qualification, this run process fetches the three primary data forms (Questions, Options, and Response) and their details.
Syntax:
After this run process is complete, the new survey component is loaded on the UI.
- Learn more about using run process and $PROCESS$ commands at Using-Run-Process-and-PROCESS-commands.
- Learn more about PERFORM-ACTION and other workflow commands at PERFORM-ACTION and other workflow commands.
MAPGET function
The MAPGET function returns the value of the key mentioned in its arguments. It returns the current response of the Question ID.
Syntax:
Learn more about the MAPGET function at Functions.
Task 7: Map keywords with fields to store survey data
To retrieve and store the information about a question and the corresponding response from a user, you must map the following keywords with the corresponding fields on your form:
Keyword | Description |
---|---|
$SURVEYQUESTION_CURRENTID$ | Holds the question ID of the last responded question |
$SURVEYQUESTION_LASTRESPONSE$ | Holds the old value of a response in case the user updated the response |
$SURVEYQUESTION_CURRENTRESPONSE$ | Holds the new value of a response in case the user updated the response |
If a user selects a new response, the value held by the $SURVEYQUESTION_LASTRESPONSE$ keyword is blank. The value held by the $SURVEYQUESTION_CURRENTRESPONSE$ keyword is the new response that was selected by the user.
If the user updates a response, the $SURVEYQUESTION_LASTRESPONSE$ keyword holds the value of the response that was previously selected by the user. The $SURVEYQUESTION_CURRENTRESPONSE$ keyword holds the value of the new response selected by the user.
To map the keywords with the fields:
- Create three fields on your form that can hold the values for the preceding three keywords. For example, Current Question ID, Last Question Response, and Current Question Response.
- Create a new active link. Learn how to create an active link at Creating-active-links.
- Create a Set Fields action and add the preceding keywords as values for three fields. For example, $SURVEYQUESTION_CURRENTID$, $SURVEYQUESTION_LASTRESPONSE$, and $SURVEYQUESTION_CURRENTRESPONSE$. Learn how to create a Set Fields action at Creating-a-Set-Fields-action.
Task 8: Get the survey status
To get the survey status, you must use the GETSURVEYSTATUS function in Developer Studio. This function returns the status based on whether all questions are answered or not.
Returned value | Description |
---|---|
0 | Returns 0 if all questions are not answered |
1 | Returns 1 if all questions are answered |
To get the survey status:
- Create a field, for example, Survey Status on your form.
- Create a Set Fields action and then as a value for this field, select GETSURVEYSTATUS in the Expression Editor. Learn how to create a Set Fields action at Creating-a-Set-Fields-action.
- In Available Fields, select the field ID.
Learn more about the GETSURVEYSTATUS function at Functions.