Add more contacts after company insert

In this section of the tutorial, you will learn how to configure the newly created insert page (insertcomcon), so that you can decide if you want to add more contacts after the submit or not.

To accomplish this, you will need a way for the user to pass his decision (a menu, radio-button, checkbox), and a way to redirect to a specific page based on a condition. As for the passing the decision part, there is no problem, only the choice of the HTML form elements remains. For the conditional redirect action, however, you would have some hand-coding to do.

MX Kollection 3 has this need covered too, however, through the Redirect To Page trigger. As all the other MX Kollection 3 triggers, this one can be turned into a conditional trigger, simply by using the expression builder on the advanced tab.

To add this functionality, you will have to alter the design of the insert page (e.g. insertcomcon), and only then add the application logic that performs the actual task.

Alter the page design

This alteration concerns adding a new form element, so that the user option of whether to add some more contacts or not can be passed to the trigger. The simplest of elements that can be used effectively is a checkbox. To change the design, follow the next steps:

  1. Click on the last row that contains a text box. If you haven't removed any fields in the wizard configuration, it should be the row containing the birthday field.
  2. Add a new row below the current selection. To do this, right-click in the cell and select Table -> Insert Rows and Columns. Click on OK in the dialog box that opens.
  3. In the new row,type in the first cell "Add more contacts" (without the quotes) as a label for the checkbox.
  4. Click in the second cell. Here is where you will insert the checkbox. Add it from the Forms tab of the Insert bar, by clicking on its button. Configure the checkbox, by changing its name to "addmore" and set the Checked value field to 1. Also, leave the Initial state on the unchecked setting.


       
  5. Now the checkbox appears on page, but to ease future work you should add it to the Bindings panel. Click on the Plus(+) button of the Bindings panel and select Form Variable.
    Note:
    For ASP users, you should select the Request Variable type, then in the dialog box select Request.Form from the drop down menu.
  6. Enter the checkbox name in the dialog box's text field: addmore. Click on OK to add the new variable to the environment.


                    
  7. These are all the changes you will make in the page design. Save the page, and proceed to adding the trigger for the redirect operation.

Add application logic

The actual operation will be based on the Redirect To Page trigger, which will be set to start on a custom condition: that the Add more contacts checkbox is checked.

To add and configure the redirect trigger, follow the instructions below:

  1. Click on the Plus (+) button of the Server Behaviors tab, and select MX Kollection -> Forms -> Redirect to page. This will open the redirect trigger dialog box.
  2. For this trigger you will have to set options both for the Basic and Advanced tab. On the Basic tab, just enter the page to which the user will be redirected. Either enter its name, or use the Browse button to locate the insert page in the contact folder.


                       
  3. Move on to the Advanced tab, where you can define a starting condition for the redirect. You can either write the condition in the text-field, or use the condition builder, by pressing the Build Condition button. Let's use the latter.


                 
  4. The Condition Builder offers an easy way to create starting conditions that use two or more terms, and an operator. Its dialog box is divided into two tabs: Basic, where you can define a simple condition based on two terms and the default operators, and Advanced, where you can enter more complex conditions in a text-area. Since in this tutorial you'll only need to compare if the addmore variable has been checked, the Basic tab will suffice.
  5. It's time to build the actual condition. Follow the instructions below to construct it:
    · For the first term you will use the Form Variable defined when you've added the checkbox into the page. Click on the blue lightning bolt icon to open InterAKT's dynamic data selector. Here, select the addmore Form Variable.



    · Click on OK and notice that a dynamic construct has been added into the first element's text field.
    · Next comes the operator. From the drop-down list select "==" to check for equality.
    · For the second operator, you will use an entered value. Since the Checked Value property for the checkbox has been set to 1, this is the value that the condition should use. This way, if the trigger's condition that the checkbox value equals 1 is true, the redirect will take place. Otherwise, the default redirect of the insert operation (to the main index) will execute.



    · Click on the OK button to accept the condition. The expression will be displayed in the Redirect To Page trigger's Advanced tab, in the Condition text field:


                 
  6. Now the trigger configuration is finished, and you can click on the OK button to add the trigger into the page. Then you can save it, upload it on the server and test it in the browser.

When you add a company through this insert form, if the Add more contacts checkbox is checked, when submitting the page, you will be taken to the contact insert page, where you can continue adding entries:

 

In the next topic of the tutorial you will create a page that will automatically send birthday greetings to your contacts.