In a number of forms, there will be one or more required fields for the user to fill in. In our New Car screen, we will make the Car Name field required. First, let's inform the user the field is mandatory by putting a '*' in the placeholder text.

Update the Car Name Placeholder

  1. Customize the New Car screen.
  2. Select the CarName Text Field.
  3. Change the Placeholder text so that it has a * in the name (e.g. *Car Name).

Thanks to the placeholder text and the asterisk, we have indicated to the user this field is required. But what if they ignore us and try to save the record without inputting a car name? Obviously we don’t want to save a car with no name, so we’ll have to create some “checks and balances” to make sure Method won’t actually let a user save a record with no car name. We can do this through use of conditionals.

Add a Conditional Statement Action

A conditional is a way for Method to carry out different actions based on a certain condition. In our example, we want to check if the Car Name field is empty or not. If it’s empty, we want a “show message” to pop up, telling the user to add a name. If the field has a value in it, we want the record to save as normal!

  1. Select the arrow on the Save button and choose its Click event.
  2. Search for and add the Conditional Statement  action.

The Conditional Statement action is done differently than other actions. Notice there is an If...then and an else connected by a blue line?

 This will be easier to explain when the statement is set up so let's add a condition.

Add a Condition

1. In the right panel, click Add a condition.

 The first line, If All of the following are true: is used for multiple conditions, so we can ignore that for now.

2. For the first dropdown, search for the CarName field and select it.
3. The next dropdown is operator for the comparison. Set it to “Is Not Empty”.
4. Make an Internal Note of this - “If CarName not empty”.

This is the condition we are setting up: we’re checking if the “CarName” field is not empty. Note that the Internal Note shows up beside the Conditional Statement? It saves a lot of time to know what your conditional statement is asking.

Now, this condition can be one of two things: True or False. If the answer is “True - the field has a value in it”, then actions indented under If...then are done. If the answer is “False - , the field is empty”, actions indented under the Else condition are done. Let’s deal with If first.

If...then - Condition is True

  1. Select the Save All action by its line number and drag it underneath the If...then statement, making sure it is indented.
  2. Then select the Call Another Action Set action by its line number and drag it under Save All. This action should also be indented.

There we go: if the CarName field is not empty, all the actions underneath If...then will run in order (which means the record will save as normal.) Now let’s deal with the other potential - if the CarName field IS empty.

Else - Condition is False

1. Hover over the Else  line to see the plus symbol and select it to add an action underneath the Else line.

2. Search for and select the Show Message action. This will bring up its properties on the right.
3. For Title, type in: “Required Fields Missing”. This is the title of the message window that will pop up.
4. For Message, type: “A Car Name is required. Please enter a name.”
5. Fill in an Internal Note: “Car Name is a required field.”.
6. You're done! Your Conditional Statement should now look something like this:

7. Close the Action Editor and then close Design Mode.

Great! The show message action has been created.

Now, if a user clicks Save with nothing written in the field, the message will appear. And if the user has included a name, Save will save the record as normal!

Next Mission >

Did this answer your question?