12: Add checkboxes

You know what would be awesome? If we could select specific records in the grid and activate and deactivate them all at once. For those following along, this would be helpful to Valerie if she was sending multiple cars to maintenance at the same time - she could mark all of them as inactive all at once, rather than choosing individual records to change. So let’s set that up!

Add a Checkbox Column

  1. From the Car List screen, click Customize.
  2. Select GridCar. In the properties panel on the right, expand the Columns header and click "Has a checkbox column".

And now each row has a checkbox column! That was easy. Now, let’s set up some buttons to do something with those checked rows. First we need a separate section for the buttons.

Add a New Section

  1. Drag a new Section right above SectionList.
  2. Select the section and rename it SectionGridActions, remembering to hide the Header/Title bar.
  3. Change the padding to 1x EXCEPT FOR THE BOTTOM padding. We want it nice and close to the grid.
  4. Select the section named SectionList and change the Top Padding to None.

Okay, the section is all set up. Now onto the button! 

Add a Button

  1. Drag a button object into SectionGridActions.
  2. Select the button and change its Text to “Deactivate”
  3. Change the Text Size to Small.
  4. Now, go into the Click event of the Deactivate button.

Let's start plotting actions. This next action we’re going to use is called a loop. A loop is a way for Method to perform the same action a set number of times. In this particular case, we want to perform an action for each record the user has checked in the GridCar.

Add Action Loop Through Gird

  1. Add the action Loop Through Grid.
  2. Step 1 asks us which Records we wish to loop through. We want the ones in the GridCar grid, so select that.
  3. In Step 2, check the checkbox: Only select rows that are checked.
  4. Make sure to add your Internal Note: “Loop through checked rows”
  5. Click Save & Back.

Now this loop will go through each checked record in the grid. If you checked three rows, the loop will run three times: once for each row. Of course, we want it to run an action for each row, so let’s add that next.

Add Action Update Fields in Table

  1. Add the action Update Fields in Table.
  2. Click Save & Back.The action isn’t configured yet, but there’s a step we need to take before we complete that process.
  3. Drag the “Update Fields in Table” action so that it is indented underneath the Loop.What does this mean? For each record you check in the grid, it will apply the “Update Fields in Table” action! Let’s program that action now.
  4. Click the pencil beside the action “Update Fields in Table”
  5. Step 1: For table, choose “Cars”.
  6. Step 1: For Where, select Open Criteria Builder.
  7. Criteria Builder 1st Value should read: “Field” “RecordID”.
  8. Criteria Builder Comparison should be the default setting: “Equals”.
  9. Criteria Builder 2nd Value will be: “Loop” “RecordID”. Once this is done, click Save & Back.
  10. Step 2 is Add a Field. For Field, let’s choose IsActive. The Value From should be Yes/No, and the Value will be No. This means for each record checked in the grid, Method will set its IsActive field to “No”, effectively deactivating the record! 
  11. Make an Internal Note “mark checked records as inactive”, then click Save & Back.

Add Action Refresh Grid

The last thing we should do is add a Refresh the Grid action. This won’t be in the loop, by default, but you’ll want to make sure it isn’t (do not indent it), because we only want Method to refresh the grid once, at the end of the loop. If it ends up in the loop, Method will refresh the grid every time we process a record - and that becomes a real pain for everyone involved.

  1. Add the action - Refresh Grid.
  2. For Grid, choose “GridCar”.
  3. Click “Clear all checkboxes” – this will get rid of all the checkmarks in the check boxes when the grid refreshes.
  4. Make an Internal Note: “Refresh GridCar”.
  5. Then click Save & Back > Save & Close > Save > Close.

Add a New Button to Activate Selected Records

We now have a button designed to deactivate selected records, so logic would dictate we’d also want a button to reactivate selected records too, right?  It certainly would, but here’s the thing: the process to create the Activate button is almost exactly the same as the process we just went through. So instead of walking you through all those steps again, here are the pertinent changes:

  • On Step 2, select the button and change its Text to “Activate”.
  • On Step 19, the Value should be set to “Yes”.
  • On Step 20, make an Internal Note “mark checked records as active”.

All the other steps are exactly the same.

Next Mission >

Did this answer your question?