Salesforce

Using the Validation Component (Magic xpi 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Using the Validation Component (Magic xpi 3.x)

The following example demonstrates how to use the Validation component in a Magic xpi flow. In this scenario, the component is used to verify an order that arrives through an HTTP invocation. If the contents of this invocation are validated, the flow execution continues.

  1. Define a new HTTP service. Click here to learn how to do this.

  2. Click the Endpoints button in the HTTP Service Settings dialog box. The Endpoint dialog box opens. Here, in the left hand pane, you should enter a suitable endpoint name by clicking New. In the right hand pane, click New to add arguments to the endpoint.

  3. For this example, you should add two arguments. The first argument's data type should be Alpha, and the second argument's data type should be Numeric. When you have done this, click OK to close the Endpoint dialog box, then click OK to close the HTTP Service Settings dialog box.

  4. The next stage is to define the required flow variables. Select the Flow menu, and click Variables. In the Variables for Flow dialog box, click New. Define the F.Name1 variable's data type as Alpha. Click New again, and define the F.Name2 variable's data type as Numeric. Notice that these data types correspond to the data types that you defined in the endpoint's arguments (above). Then click New for a third time, and enter the variable's name as F.Valid_Input. This variable's data type should be defined as Logical. Click OK to close the dialog box.

  5. Drag the HTTP component to the Trigger area of the Magic xpi Studio. The Component Properties dialog box opens. Click the Settings tab. You will see that the values are those that you defined in the HTTP Service Settings dialog box.

  6. Click Configuration to open the Component Configuration: HTTP dialog box. The read-only Service Name field should display the name that you defined in the HTTP Service Settings dialog box. In the Endpoint Name field, select the endpoint that you previously defined (above). In the Argument Details section, you will see the argument values that you defined earlier.

Here, in Argument1's Mapping Variable column, click to open the Variables List. From this list, select the F.Name1 variable.

In Argument2's Mapping Variable column, click to open the Variables List. From this list, select the F.Name2 variable.

  1. Click OK to close the Component Configuration: HTTP dialog box, followed by OK to close the Component Properties dialog box.

  2. Once you have set up the HTTP trigger, you need to be able to validate the data that it receives. In this example, the Alpha and Numeric data types need to be validated.

    To do this, drag the Validation component into the flow area. The Component Properties dialog box opens. Click Configuration to open the Direct Access Method: Validation dialog box.

  3. First, you should define the validation parameters for the Alpha data types. In the Direct Access Method: Validation dialog box, click New. Select the Alpha Field Value method from the drop-down list. Enter the following values for these parameters. Parameters in bold are mandatory.

Parameter

Value

Input Value

Click to open the Expression Editor. Click to open the variables list. Select F.Name1 from the list. Click Verify to check the validity of this variable, and then click OK to close the Expression Editor.

Valid Values

Click to open the Expression Editor. Enter the valid values that you want to check for. For example, 'ABC'. Click Verify to check the validity of this value, and then click OK to close the Expression Editor.

Return Value

Click to open the Variables List. Select F.Valid_Input (you defined this earlier), and click Select.

Note:

It is not necessary to continue the data validation process if one of the data types is not validated. By adding a condition to this method, you can terminate the validation process, and therefore the flow, if a particular value is not validated.

To do this, click the button in the Condition column in the left hand pane, next to the Alpha Field Value method name. When the Expression Editor opens, click to open the variables list. Select F.Valid_Input. Click OK to close the Expression Editor.

  1. Next, you should define the validation parameters for the Numeric data types. Staying in the Direct Access Method: Validation dialog box, click New. Select the Numeric Field Range method from the drop-down list. Enter the following values for these parameters. Parameters in bold are mandatory.

Parameter

Value

Input Value

Click to open the Expression Editor. Click to open the Variables list. Select F.Name2 from the list. Click Verify to check the validity of this variable, and then click OK to close the Expression Editor.

Range Type

Select Minimum To Maximum from the drop-down list.

Minimum

Enter 10 here.

Maximum

Enter 25 here.

Return Value

Click to open the Variables List. Select F.Valid_Input (you defined this earlier), and click Select.

  1. Click OK to close the Direct Access Method: Validation dialog box, and then click OK to close the Component Properties dialog box.

  1. Drag a Save Message service into the flow as a child to the Validation component. In the Name field, enter Invalid Input. In the Message field, click to open the Expression Editor. Enter 'Invalid Input', and click OK.

  2. Drag another Save Message service into the flow as another child to the Validation component. In the Name field, enter Valid Input. In the Message field, click to open the Expression Editor. Enter 'Valid Input', and click OK.

Using the Validation component in this way means that if data received via HTTP is not validated, the flow will not be executed.

Reference
Attachment 
Attachment