In the previous mission, we set up the New Car screen with a second version so we could alter it to serve a second purpose: editing a car.
In this mission, we wil do just that. Repurposing the New Car screen, so it can also be used to edit a car.
Rename the Screen
1. Customize the New Car screen. You will be editing the second version automatically (unless, for some reason, you logged in as a different user.)
2. Select the NewCar text object at the top, the one used in the header, and change the text to "New / Edit Car".
3. Go to the properties of the screen itself by clicking the paper icon.
4. Change the Name of the screen to "New / Edit Car".
5. Save the Screen and Close it.
That's it. I know, we didn't do much other than rename the screen! So how do we use it to edit a car? The easiest way to do that would be to click on a car on the grid in the Car List screen. So let’s set up the functionality!
Editing Car List Grid
1. Go to the Car List screen and click Customize.
2. Click the down arrow ( ▼ ) on the GridCar object and select the Row Click Event.
3. Find and add the action Go To Screen.
4. Under Navigate to, choose Cars app. For the new dropdown that appears, choose the New / Edit Car screen.
5. For Set a screen active record ID, select Set Active Record ID.
6. For Use this active record ID, search for and choose GridCar - Record ID.
7. Remember to include an Internal Note: “Go To New / Edit Car Screen”.
8. Close the Action Editor and then close Design Mode.
Now, when you select a car in the grid, you will be taken to the New / Edit Car screen with all the fields already filled in! You are editing the vehicle. By making changes and hitting save, you will update the car in the Cars table.
Of course, if you have no vehicles showing up in the list, you may need to create one. Good thing you made a screen to add a new car.
For more information on how Method is able to load in these fields, you will need to know more about the Screen Active Record ID. For more information, read our article on the action Set Active Record ID for Screen. Although we don't use this action, it will give you a good sense on what the Screen Active Record ID is.
Coming up next...
Now that you can edit a car, you probably want the option to delete the car as well. That's coming up in the next mission.