How To: Add Lookup Information to a Form
In the following scenario, you are using a Region SmartObject Lookup on a view containing other information about a customer view. Although only the Region ID is stored in the Customer SmartObject, the names of the regions are displayed in a popup dialog for you to choose from. These names are stored in the Region SmartObject.
Steps
Follow the steps below to set up the Customer view with Region SmartObject Lookup.
- Create two SmartObjects called Customer and Region with following properties:
Customer SmartObject Property Type Key Required Unique CustID Autonumber Yes No Yes CustName Text No No No CustNumber Number No No No RegionID Text No No No Region SmartObject Property Type Key Required Unique RegionID Autonumber Yes No Yes RegionName Text No No No RegionAlias Text No No No - Generate an Item View for the Customer SmartObject and a List View for the Region SmartObject.
- Edit the Customer Item View, select the Region ID field, and then click the Change Control icon.
- Change the control to Lookup and then click OK.
- You must specify the Region ID field as the data source for the Lookup SmartObject. Select the Region ID field and click the ellipsis in the SmartObject option of the Data Source section.
- Select the Region SmartObject and click OK. The Method, Value and Display is populated as shown below. Click OK.
-
Navigate to the Rules tab of the step and click Add Rule. Select When a control on the View raises an event. Select the RegionID Lookup control and select Clicked. Click the Actions tab at the top.
-
Select Open a subview located in the Subview Interaction section. Select the Region List view. This rule opens the Region List view in a subview when the RegionID lookup control is clicked. Click OK.
-
Note that the Region List subview executed Initialize rule is added automatically when adding the rule. This rule populates the Region List subview.
- Click Add Rule again. Under Events, in the Subview Events section, select When a subview executes a method. Select the Region List subview and List item double click as the method. Click the Actions tab.
- Select Transfer data
-
Click on Configure and map the RegionID as shown below. Click OK.
- Select Close a subview or subform under the Subview Interaction section. Click OK and Finish to save the view. This rule transfers data from the Region List subview to the Customer View when an item is double clicked on the subview. The Region List subform then closes.
- Enter some region information in the Region SmartObject. Do this by creating an Item View and using that to fill in some regions.
- Run the Customer Item view. Click the ellipsis in the Region ID control.
-
The Region List subview opens with the data you entered in step 14. Double-click a region. Note how the subview closes.
- The item you double-clicked on the Region List subview is added to the Customer Item view.