Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Login to portal with a valid developer account.

  2. Navigate to LOW CODE → Properties.

  3. Click the plus + icon at the top.

  4. Select App and create a new app with name: io.pipeforce.tutorial-03-forms.

  5. Select this app and click again the plus + icon.

  6. Now select Form Schema and create it inside this app with name: person.

    9.png

  7. The new schema was created and pre-filled with an example person schema.

  8. Later, you can edit this form schema and remove, change or add data fields to your form.

  9. For this tutorial, do not change anything and leave it as it is. 

Info

At this step you have created a Form Schema which defines the fields and their data types of the form.

For more information go to the public docs: Form Schema.

...

  1. Go to LOW CODE -> Properties.

  2. Select your app io.pipeforce.tutorial-03-forms in the tree.

  3. Click the plus + icon.

  4. Select Form Config.

  5. Create a new Form Config with name: person

  6. In the property tree, select your app and click on the plus icon + to create a new property inside.

  7. Give a name to the Form Config then click Create.

  8. A new Form Config was created for you with a pre-configured title and configuration.

  9. Leave this Form Config as it is for now.

10. Since we did not specify any layout information here, the default layout will be used: All fields defined in the Form Schema will be displayed in vertical format.

...

Info

For more details go to the public docs: Form Config.

At this step you have created a Form Config which defines the configuration and optionally layout customization, validation rules and script references.

Step 3: Execute the Form

After the Form Schema and the Form Config have been created, you can open your form.

To do so follow these steps:

  1. Navigate to APPS -> Installed Apps.

  2. Click on the app io.pipeforce.tutorial-03-forms.

  3. Click on person.

  4. Now you should see the form with the example fields like this:

10.pngImage Added

Submit the form

  1. Add valid values in any of the fields.

  2. Click on SUBMIT.

Noteworthy

After you clicked on SUBMIT, the form data will be validated and then send to the server as JSON. This JSON will then be stored to your app's data folder: io.pipeforce.tutorial-03-forms/data/...

Any new submit will create a new entry in the data folder with a random uuid.

The reason why this works this way is because in the Form Config, the output path was configured to this location, like this:

Code Block
"output": "$uri:property:global/app/io.pipeforce.tutorial-03-forms/data/person/"

Note: Since this path ends with a /, a new entry is created with a random uuid every time you write to this URI location.

Info

In the next step of this tutorial, you will learn how to handle such a form submit in the backend in order to execute some additional action after the user has submitted a form.

Step 4: Handle the Form Submit

In this step you will learn how to handle a Form Submit at server side and add logic to be executed after submit.

Info

Noteworthy

  • After a submit, the form data will be send as JSON to the server.

  • By default this JSON is stored in the property store as configured by the output parameter in the Form Config and the event property.created will be fired.

  • Optionally, you can listen to the property.created event and trigger the execution of a pipeline.

  • But this is optional. By default, form data is stored in property store so it doesn't get lost and you can process them at any time later.

Follow these steps in order to trigger a pipeline after the form was submitted:

This pipeline should then send an email.

  1. Go to AUTOMATION -> Properties.

  2. Select your app io.pipeforce.tutorial-03-forms.

  3. Click the plus + icon.

  4. Click Pipeline and create a new pipeline

  5. Give the pipeline a name and then click Create.

  6. Copy and paste this YAML script to the pipeline editor and overwrite any existing content:

Code Block
languageyaml
pipeline:
  - event.listen:
      eventKey: property.created
      filter: ${body.target.path.contains('global/app/io.pipeforce.tutorial-03-forms/data/')}
  
  - mail.send:
      to: name@email.tld
      subject: "Form was submitted"
      message: |
        The form was submitted:
        ${body.target}

As you can see, this pipeline listens to the property.created event. Since the form submit writes to the location global/app/io.pipeforce.tutorial-03-forms/data/ (as configured by the output parameter) you can listen to this write event and execute your business logics. Which is sending a simple email in this example.

  1. Change the email address name@email.tld to your own address.

  2. Save the pipeline. After save, the pipeline will be automatically registered as a listener to the property.createdevent.

  3. Execute the form again.

10. You should now receive a new email on any form submit.

Info

In this step you have learned how to execute logic at server side after a form has been submitted.

Step 5: Customize Form Layout

In this step you will learn how to change the default form layout

Info

Noteworthy

  • By default if nothing is specified, the default layout will be used which lists all fields vertically, one after another.

  • You can change this default layout in the Form Config.

  • "Layouting" means changing the orientation, placement and styling of the form and its fields.

Follow these instructions in order to change the default layout of your form:

  1. Go to AUTOMATION -> Properties.

  2. Open the Form Config form/person inside your app io.pipeforce.tutorial-03-forms.

  3. Replace the content of the Form Config by the JSON listed below, and then click SAVE

Code Block
languagejson
{
  "id": "person",
  "title": "Add person",
  "public": false,
  "description": "",
  "schema": "$uri:property:global/app/io.pipeforce.tutorial-03-forms/schema/person",
  "output": "$uri:property:global/app/io.pipeforce.tutorial-03-forms/data/person/",
  
  "layout":{
    "orientation":"vertical",
    "items":[
      {
        "orientation":"horizontal",
        "title": "Name",
        "border": true,
        "items":[
          {
            "field":"firstName"
          },
          {
            "field":"lastName"
          }]
      },
      {
        "field":"age"
      },
      {
        "field":"gender"
      },
      {
        "field":"birthDate"
      }
    ]
  }
}

As you can see in the Form Config, the layout part was added which defines a different orientation of the fields.

  1. Navigate to APPS -> Installed Apps and click your app io.pipeforce.tutorial-03-forms.

  2. Now you should see that the “person” tile has changed to “Add person”. Click it.

  3. Here you can see the changed layout: first Name and last Name fields are now in the same line (horizontal) and all other fields are in separate line (vertical):

...

Info

For more information about layout options, go to Form Config & Layout.