Configure an Action to Clear a View or Form
This how-to illustrates adding a rule action that clears a view, or clears multiple views on a form. For example, you want form fields cleared after someone submits the form. You might use this action as a visual indicator the form submitted successfully, or to clear fields so that someone can use the form for a new submission.
A rule that clears two views after you submit a form
This section describes how to add a rule action at the view level that clears the view fields after you click a button.
- Edit the Contact Item View. From the Rules screen, edit the When Create Button is Clicked rule.
- You see the action that creates a record. You add the clear method action below. With the Actions tab active, click Execute a method on the View to add it to the rule definition pane.
- Click select method and select Clear (no additional configuration is needed). Click OK to save the rule. Click Finish to save and exit the view.
- To test the rule action, run the view. Select the view and click Run.
- Enter content into the view fields and click Create. The view should clear after K2 creates the SmartObject record.
This section describes how to add rule actions at the form level that clears multiple views after you click a button.
- Edit the Contact Form. From the Rules screen, edit the When Submit Button is Clicked rule.
- You see two actions that create records for the item and list views. You add the clear method actions below. With the Actions tab active, click Execute a View method to add it to the rule definition pane.
- Click select View and select Contact Item View. Click select method and select Clear.
- Click Execute a View method to add a second instance of the action to the rule definition pane. Click select View and select Contact Edit List View. Click select method and select Clear. You now have two methods that clear each of the views on this form. Click OK to save the rule. Click Finish to save and exit the view.
- To test the rule actions, run the form. Select the form and click Run.
- Enter content into both view fields and click Create. The views should clear after K2 creates the SmartObject records.
- Cleared content cannot be retrieved if you have not saved it in a previous rule action. If you intend to reuse content, make sure you add a rule action to create or save before clearing view fields.