How To: Use a Parameter to Transfer Data from a SmartForm to a SmartObject

This article illustrates how to save parameter data to a SmartObject. In this example, you have a view with three parameters. One parameter contains a static value and you enter the other two values. You configure a rule to execute a SmartObject's create method, which saves the values of all three parameters in the SmartObject.

You may want to use this approach when you have a view based on one SmartObject but you need to update data in a secondary SmartObject that is not bound to the view.

Transferring view parameter data to a SmartObject
Transferring Parameter Data

Scenario

In this scenario, you want to save parameter values to a SmartObject for future use. The SmartObject is unbound from the view, meaning there is no relationship or link between the view and SmartObject. This is typically not the case as you normally create views based on SmartObjects, but in this scenario, you are using the view to simply display and gather data. Keep in mind that you can use this approach in a bound view to save data in a SmartObject other than the one used as the data source for the view.

Steps

Begin by building a SmartBox SmartObject to store the parameter values. Next, build a view but do not link it to the SmartObject. The SmartObject remains unbound. Add data label controls to the view along with a button control. Add three parameters. Finally, add a rule that executes when you click the button. You have two rule actions: the first transfers the parameter values to the data label controls, giving you immediate feedback of the rule execution. Second, execute the create method of the SmartObject to add a new item based on the parameter values. You test this scenario by running the view with parameters.

Setup Steps

The following steps set up the scenario from start to finish. If you want to skip the setup steps and view the topic step, go to Configure a Rule to Transfer and Save Parameter Data.

  1. In the Designer, create a SmartBox SmartObject called Parameter Values. Add the following properties: Name (Text), Date (Date), and Shift (Text). (Optional) Create categories first to keep your work organized.
    1. Launch the Designer.
      If you do not know how to access the Designer, see Accessing Sites.
    2. Create categories to keep your work organized. Right-click All Items and select New Category. Use the image below for an example of category names.
      Create Categories
    3. Right-click the Parameters category and select New SmartObject. Name the SmartObject
      Parameter Values
      and confirm the type is set as SmartBox. Click Create.
      Create SmartBox SmartObject
    4. Add three properties: Name (Text), Date (Date), and Shift (Text). Click OK. Click Finish to save and exit the SmartObject.
      Add Properties
  2. Create a view called Sample View. Create the layout table with one column and four rows. Add three data labels to the first three rows. Add a button control to the fourth row. Add three parameters using the table below as a guide for the name, date, and default values.
    NameData TypeDefault Value
    NameText
    DateDateTime
    ShiftTextDays
    1. Right-click the Parameters category and select New View. Name the view
      Sample View
      and confirm the type is set to Item View. Click Create.
      Create View
    2. Click Create Layout Table Only. Specify the number of columns and rows for your layout table. For Columns, enter
      1
      and for Rows, enter
      4
      and click OK.
      Create Layout Table
    3. From the Toolbox (on the left side of your screen), drag a Data Label control into the first three rows. Drag a Button control into the fourth row.
      Add Controls
    4. Next, add three parameters. Click the Parameters tab. Click Add Parameter. Use the table below as a guide for the name, data type, and default values. The Shift parameter has a static value, Days. You add the other two parameter values when you run the view.
      NameData TypeDefault Value
      NameText
      DateDateTime
      ShiftTextDays
      Add Parameters

Configure a Rule to Transfer and Save Parameter Data

In the next step, you add a rule that contains two actions: transfer parameter values to data labels and save the values to a SmartObject.

  1. Add a rule with two actions: the first transfers parameter values to the data label controls, and the second creates a list item in the Parameter Values SmartObject. The rule executes when you click the button on the view.
    1. Click the Rules tab. Click Add Rule.
      Add Rule
      Rules consist of events, conditions, and actions. A valid rule contains at least one action.
      • Events define when the rule should run, such as when a button is clicked, or when the form loads. (Events are optional, you can define "event-less" rules that you can call from other rules.)
      • Conditions define whether the rule should run. If the criteria are true, continue the rule, and if the criteria are not met, stop the rule. For example, a condition might evaluate a form to confirm that required fields have content. (Conditions are optional - not all rules will require conditions.)
      • Actions define what the rule should do. For example, show a message, start a workflow, or enable a form field. Rules can contain multiple actions that are run in sequence or in parallel.
    2. When you click the button control, you want the three data labels to be populated with the three parameter values. (Remember, one value is static and you enter the other two values when you run the view.) Therefore, the event for this rule is the button click.

    3. With the Events tab active, click When a control on the View raises an event to add it to the rule definition pane. (Note that you can search for events or scroll through them.) Click select control and select Button. The select event link automatically changes to the default action for buttons: Clicked.
      Add Event
    4. Click the Actions tab. The first action transfers the parameter values to the data labels. This action is a confirmation that the rule executed. Search for
      transfer
      click Transfer data and click configure.
      Transfer Data
    5. You transfer the parameter values to the data labels. Expand the Context Browser > Sample View > Parameters node. Map the Name parameter to the Data Label control. Map Date to Data Label1. Map Shift to Data Label2. Click OK. When you click the button, the data labels show the parameter values. This gives you a visual indication the rule executed.
      Map Parameters to Controls
    6. Next, you save the parameter values to your SmartObject. Since the SmartObject is unbound from the view; there is no relationship between the view and the SmartObject data source.

    7. With the Actions tab active, click Execute a SmartObject method, select the Parameter Views SmartObject, Create method and click configure.
      Execute a SmartObject Method
    8. Map the Context Browser > Sample View > Parameters > Name property to the Input Properties > Name text box. Map the Date and Shift parameters to their corresponding input properties. (The ID is created when the new item is added.) Click Finish to save the action and OK to save the rule. Click Finish to save and exit the view.
      Map Parameters
  2. Test the data transfers by running the view from the Designer. Run the view with parameters. Enter a value for the Name parameter and enter a Date. Do not enter a value for the Shift parameter as it has a default value of Days. Click the button. The data labels on the view show the date, time, and shift values. This is a visual confirmation the rule is executing. From the Management site, execute the Get List method for the Parameter Values SmartObject. You should see a list item with all three parameter values.
    1. Right-click Sample View and select Run with Parameters.
    2. Enter values for the Name and Date parameters. Remember, the Shift parameter has a default value, so you can leave it blank. Click Run.
      Run with Parameters
    3. Click the Button. The data labels show the parameter values.
      Data Labels Show Parameter Values
    4. Open the Management site in a new browser tab.
    5. From the Categories menu, navigate to and select the Parameter Values SmartObject.
      Categories Menu
    6. You see the SmartObject details in the central pane. Locate the Methods section. Click the Get List method and click Execute.
      Execute Get List Method
    7. Click Execute once again. You want to return all records, so you don't need to apply a filter. On the Results screen, you should see a list item containing the three parameter values. Click Done to exit.
      Method Results
Review

Use parameters like variables to store data within a view or form. Parameter values can be static, dynamic, or entered at runtime. You can transfer parameter data to SmartObjects by executing a SmartObject method such as create or save. SmartObjects do not have to be bound to the view. In most cases, you use rules to integrate with parameter data, for example, to set or transfer values.