Salesforce

Using the Validation Component (Magic xpi 4.7)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Using the Validation Component (Magic xpi 4.7)

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 Settings dialog box's Services section. 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 Apply in the Settings dialog box.

  4. The next stage is to define the required flow variables. To do this, double-click Flow Variables under the relevant flow. In the Flow Variables repository, click Add. Define the F.Name1 variable's data type as Alpha. Click Add 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 Add 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 Save to save your variables.

  5. Drag the HTTP component to the Trigger area of the Magic xpi Studio. The the Properties pane opens. In the Setting section, you will see that the values are those that you defined in the Settings dialog box's Services section.

  6. Double-click or right-click on the component and select Configuration from the context menu to open the Component Configuration: HTTP dialog box. The read-only Service Name field should display the name that you defined in the Settings dialog box's Services section. 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.

  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 Properties pane opens. Double-click or right-click on the component and select Configuration from the context menu 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 Add. 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.

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 Add. 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.

  1. Drag a Save Message utility 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 utility 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