The Delete button shouldn't appear if the page is being used to add a new car! It should only appear if the screen is being used to Edit a car.
This is where we can use the Screen Active Record ID. Remember, when we are editing a car, the Screen Active Record ID will hold the Record ID of the car we're editing. However, if it is less than 1 or empty, then we know the user is not editing a car and we can hide the Delete button!
The tricky part is: what Event should this go in? The Screen itself has events, and the event to use is called Active Record Change. This event triggers when the Active Record changes, and it gets changed when it is assigned a Record ID!
Delete Button's Load State
First, let's make the Delete Button invisible
- Select the Delete Button.
- Under Settings, change the Load State to Hidden.
And now the button will no longer be visible. However, we want to make it visible when the user is editing a car!
Screen's Active Record Change Event
1. Select the Page Icon in the top menu to go to the Screen Properties.
2. Under Actions, select the event Active Record Change.
3. Search for and add Conditional Statement. This action should be familiar to you, because we used it previously to check Required Fields.
4. Add a condition and fill in:
- First dropdown: Search for and select Screen Active Record ID
- Comparison: Greater Than
- Third dropdown: Number - 0
- For Internal Note: "Active Record ID > 0 (User editing a car)"
5. If the Active Record ID is greater than zero, this means the user is editing a car.
6. Hover of the If...then and click the plus icon to add an action below it. Find and add Show/Hide Controls action and use these parameters:
- Control*: Delete
- Option: Show
- Internal Note: "Show Delete Button"
7. We're done! Close the Action Editor and then close Design Mode.
We now have a functional delete button and you've completed the tutorial!
Huzzah and Congratulations!