The SmartForms rules engine makes embedding notification actions easy to perform. But the default “Get Confirmation from User” notification is rather anemic — you can’t use fields or expressions within them. Fortunately, there is a way to get around that.
If all you want to do is to prompt a user with some standardized text, then the Get Confirmation from User Action should suit you fine. The rule definition allows you to enter text to specify a heading and to specify your message.
(Click the image to view it in this window. Click your browser’s Back button to return to the post.)
If, however, you want a prompt that will include some dynamic information — say, something the user has selected — then we have to get creative.
Show a Message
Instead of selecting the Get Confirmation from User Action, select the Show a Message Action.
The Show a Message Action lets you configure the prompt’s size, type, title, heading and body; and offers use of a Context Browser.
(Click the image to view it in this window. Click your browser’s Back button to return to the post.)
The key to using this type of notification action as a confirmation dialog is in the message type confirmation. Ensure you have that attribute set to Confirmation.
Rules
Unfortunately, if we just leave our notification as-is, the buttons won’t actually do anything. Also unfortunately, we can’t assign rules to the notification buttons in the way we can on forms and views. To set up our rules, we have to manufacture a condition under which the rules can operate.
Let’s say your rule definition is triggered when a view executed the List Item Click event. Perhaps it looks like this:
We need to add a couple of things. First, Add any other action below it — it won’t matter what it is, because you’re going to delete it. The addition of the action should change the rule definition to appear as follows:
Notice the insertion of the phrase, “then complete the following one after another.” That’s going to become critical for us. Remember to delete the unconfigured action you just added.
Next up, we need to manufacture our condition. In the Rule Designer, click Conditions and scroll all the way to the bottom to find category Custom Conditions. Click on an advanced condition is true and move it into position like this:
Configure the advanced condition as follows: In the Conditions pane, you may have a blank rule ready to configure. If not, click Add. You’ll see three fields, set like an equation. There is a Left field, followed by an Operator, followed by a Right field. Enter the digit 1 in both the Left and Right fields, and ensure the Operator value is set to Equals. Down in the Preview pane, you should see 1 is equal to 1, as below:
We have just created our OK button condition.
Create whatever additional rules you need to occur after the user has clicked OK. When you’re ready to create rules for the Cancel condition, return to the Conditions panel and scroll down to the Logical Conditions section. Click on Else to insert it into your rule definition:
Finally, you’re going to have to create a rule for what to do after that Else. Even if you want it to do nothing, it’s got to do something. Consider adding a hidden field to your form and transferring nothing to it.
Your final rule might resemble this:
Get the Message
When you run your form, you should see your dynamic confirmation message, with its OK and Cancel buttons.
Clicking Cancel should dismiss the message with no apparent change in your form, but clicking OK should allow the operation to continue.
Sweet, right?
You must be logged in to post a comment.