As an alternative to WebForm Designer, you can use SurveyJS Creator to create web forms. This tool is added in process steps via drag & drop like all other activities from the Activity Repository. We are not going into the individual functionalities of SurveyJS here, but rather the integration into your processes. To better understand this application, test the Survey Creator and review the End-user guide in the official online documentation.
Various form activities are available in the de.aristaflow.form.SurveyJS Activity Repository. Drag the corresponding activity onto the process step or on an edge where the new step should be created.
The types of forms that can be created with the SurveyJs are as follows:
- Generated Survey
You can use the Generated Survey for a rapid process prototyping because here you do not have to model the survey and it is created automatically based on given parameters. Just like in other AristaFlow activities, you can create input and output parameters in the wizard and map them to the existing data elements. Since generated Surveys cannot be opened in SurveyJS creator, the context menu entry for opening in creator is disabled. However, you can select the Webform Design in the wizard, so that the user is offered the three buttons Sending, Suspending, and Resetting for processing the activity as shown in following image. Of course, this is also possible for the other types of Survey (Survey and WebForm). At the end of the wizard, the parameters are assigned to the data elements. Here either the proposed assignment is accepted or a manual assignment can also be made.
In the next image you can compare the surface of generated survey with web form and default design.
Parameterhandling in SurveyJS activities¶
Immediately after integrating the SurveyJs activity, the wizard for adjusting the most important activity properties opens. On the second page Parameters you can add new input or output parameters via Add Parameter.... The parameters inserted here can then be found in the survey when you open the survey in SurveyJs Creator. At the beginning, if there are no existing data elements, then the Add Parameter for... option is of little use, as you have to link the existing data elements with input or output parameters. So if you know exactly which parameters the process needs, you can link them with Add Parameter..., otherwise you create the form with Survey Creator and then link the automatically created input and output parameters with the data elements. Before a parameter is inserted, it must be determined which parameter template it has, i.e. Default or Survey Data (see next image). The Default parameters contain single data of a certain type and are created in the same way in all AristaFlow activities. But the parameter Survey Data contains all the data of a form and can be used as described below.
The survey data contains all input and output parameters as JSON object. To be able to add survey data as a parameter, you have to define the survey first. After opening, modeling and saving the activity with SurveyJS Creator, the survey is defined and survey data is automatically generated as input and output parameter of the activity (see next image). If you link Survey Data as input or output parameter, the current activity receives all values of the previous activity as input or writes all values of the current activity as output to the JSON object. Survey data can contain more complex data or tables that would be difficult to submit individually. With the help of this parameter you can pass all activity data through the whole process. In the next image the parameters Survey Data and Name are linked as output, where Name can be accessed separately. For more information about survey data see the chapter Survey Data.
In contrast to generated Survey, you can open and edit the survey forms of type Survey and WebForm with Survey Creator. After opening and saving the activities with Survey Creator, you can no longer add the parameters via the activity wizard. The parameters can then only be managed via SurveyJS Creator. All inserted questions to Survey are automatically added to input and output parameters but are not enabled until you confirm the assignment in the actitvity wizard.
In the following example a Webform Survey without parameters is opened in Surveyjs Creator and a single input called Question1 is added.
Then the Question1 is mapped to a new data element in the wizard as an output parameter.
The result looks like this:
The parameter references can be used in instance or template names or descriptions, and in SAR rules. Further they can be used in node names or when modeling decisions. They are evaluated and replaced at runtime. The exact syntax for parameter references must be strictly followed. We set a reference to a string type parameter as follows:(%s:parameter%) , where the character after percent signs indicates the type of the parameter, i.e. 's' for String, 'i' for integer etc. For an example using parameter reference see the tutorial External survey using parameter reference.
External Survey URI¶
In the wizard on the SurveyJS page you can define an external Survey URI (a local or an http URI) from which the Survey can be read. For this, however, the survey must be saved in Json format under this URI and must be accessible from the activity at runtime.
We recommend that you develop the survey in the Online Survey Creator and save the associated Json data from the Tab Json Editor in a Json file as shown in the next example.
Then enter the file URI in the wizard on the SurveyJS page as follows and press the Rebuild Parameters to import the parameters of the integrated form.
After changing the questions in the SurveyJS Creator, the parameter mapping is automatically adjusted when the survey is saved. But if you change the survey definition by an external survey URI or open a template from a previous version in the PTE, click the button Rebuild Parameters to update the parameter mapping in the wizard so that you can map the newly proposed parameters to the data elements afterwards.
In the next picture you can see the automatically mapped parameters after integrating the external Survey URI.
Example Expression(read-only) Question¶
With the expression(read-only) question it is possible to make an output dependent on the inputs in the same step in a survey. In the following example, two entries of the type float are made in a survey form and these entries are summed up in the same step.
SurveyJs provides different types of expressions that you can use, for example, to add conditional logic to the question. The entered expession is evaluated at runtime and displayed in a read-only field in the survey. The required expression is entered in the Survey Creator in the Properties -> General -> Expression of the question. For additional help by entering expression see the online documentation of SurveyJs.
The result of the sum is adjusted at runtime according to the inputs. The form looks like this: