Answers.Body: <p>You're on the right track.</p>
  
  <p>The first thing to note is that the Send Rule field does support shorthand syntax like in your question, however, if you are using compound logic, you will want to use the full object syntax for that logic.</p>
  
  <p>So, instead of (with no reference to <code>object.</code> and single curly braces):</p>
  
  <pre><code>{ checkBoxFieldHandle == 'value' }
  </code></pre>
  
  <p>You'll want to use the full object syntax to get the expression to evaluate:</p>
  
  <pre><code>{{ object.checkBoxFieldHandle == 'value' }}
  </code></pre>
  
  <hr>
  
  <p>The next thing to note is that the checkbox field is a multi-select input, meaning more than one value can be selected. This could be present additional logic challenges for what you are trying to do but assuming you have a checkboxes field with a single checkbox or an opt-in field the logic is more predictable.</p>
  
  <p>Checkboxes are submitted as arrays, so you'll need to make sure you are targeting the correct node in the array. In the case of a single checkbox, we know the first checkbox will be index 0 in the array. Once we have the target checkbox, we can see if it's selected by checking the <code>selected</code> attribute:</p>
  
  <pre><code>{{ object.checkboxFieldHandle.getOptions()[0].selected == true }}
  </code></pre>
  
  <p>And we can update the same statement to check for <code>false</code> if we want to only send if the checkbox is unchecked:</p>
  
  <pre><code>{{ object.checkboxFieldHandle.getOptions()[0].selected == false }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-12T16:51:08.477Z
Answers.Text: Thanks for the advice! I've added `{{ object.checkboxFieldHandle[0].selected == true }}` but now the notification is always being sent, even when I didn't check the `[0]` index checkbox. Side note: the default notification template for checkboxes is sending the checkbox handle, rather than the label; for example, I'm receiving "Checkbox Field Name: checkboxFieldHandle" in the notification email, rather than "Checkbox Field Name: Checkbox Field Label." I can override that myself with a custom template, but is that a bug with the default template?
Answers.UserDisplayName: Jon Weedin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-10T11:46:30.370Z
Answers.Text: I've updated my answer with a new syntax that works in my tests: `{{ object.checkboxFieldHandle.getOptions()[0].selected == true }}`
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-10T16:59:08.540Z
Answers.Text: This worked! Thank you so much!
Answers.UserDisplayName: Jon Weedin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-12T05:02:41.470Z
Answers.LastActivityDate: 2020-04-10T11:46:02.077Z
Answers.LastEditDate: 2020-04-10T11:46:02.077Z
Answers.UserDisplayName: Ben Parizek
Body: <p>I'm using Sprout Forms 3.8.0.2 and Craft CMS 3.4.5. My client wants the email notification to go to different email addresses based on whether or not a form checkbox is checked. My plan is to create a new notification for each checkbox value, with the checkbox logic in a custom rule. I've read through the documentation, but I can't figure out how to write the code that checks whether a checkbox is checked. I think it's something like
  <code>{ checkBoxFieldHandle == 'value' }</code> or <code>{ checkBoxFieldHandle.valueBeingChecked.selected }</code> but neither of those are sending any notifications after a test message. Any advice on how to do this? Thank you!</p>
  
Tags: <craft3><plugin-sproutforms>
Title: Sprout Forms - Notification Based on Checkbox Value
ThreadText: # Sprout Forms - Notification Based on Checkbox Value
  
  (Asked by: username_0 on 2020-02-11)
  
  I'm using Sprout Forms 3.8.0.2 and Craft CMS 3.4.5. My client wants the email notification to go to different email addresses based on whether or not a form checkbox is checked. My plan is to create a new notification for each checkbox value, with the checkbox logic in a custom rule. I've read through the documentation, but I can't figure out how to write the code that checks whether a checkbox is checked. I think it's something like
  `{ checkBoxFieldHandle == 'value' }` or `{ checkBoxFieldHandle.valueBeingChecked.selected }` but neither of those are sending any notifications after a test message. Any advice on how to do this? Thank you!
  
  **Tags:** craft3, plugin-sproutforms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-12. Score: 2
  
  You're on the right track.
  
  The first thing to note is that the Send Rule field does support shorthand syntax like in your question, however, if you are using compound logic, you will want to use the full object syntax for that logic.
  
  So, instead of (with no reference to `object.` and single curly braces):
  
  ```
  { checkBoxFieldHandle == 'value' }
  
  ```
  
  You'll want to use the full object syntax to get the expression to evaluate:
  
  ```
  {{ object.checkBoxFieldHandle == 'value' }}
  
  ```
  
  ---
  
  The next thing to note is that the checkbox field is a multi-select input, meaning more than one value can be selected. This could be present additional logic challenges for what you are trying to do but assuming you have a checkboxes field with a single checkbox or an opt-in field the logic is more predictable.
  
  Checkboxes are submitted as arrays, so you'll need to make sure you are targeting the correct node in the array. In the case of a single checkbox, we know the first checkbox will be index 0 in the array. Once we have the target checkbox, we can see if it's selected by checking the `selected` attribute:
  
  ```
  {{ object.checkboxFieldHandle.getOptions()[0].selected == true }}
  
  ```
  
  And we can update the same statement to check for `false` if we want to only send if the checkbox is unchecked:
  
  ```
  {{ object.checkboxFieldHandle.getOptions()[0].selected == false }}
  
  ```
  
  > **Comments:**
  > **username_2**: Thanks for the advice! I've added `{{ object.checkboxFieldHandle[0].selected == true }}` but now the notification is always being sent, even when I didn't check the `[0]` index checkbox. Side note: the default notification template for checkboxes is sending the checkbox handle, rather than the label; for example, I'm receiving "Checkbox Field Name: checkboxFieldHandle" in the notification email, rather than "Checkbox Field Name: Checkbox Field Label." I can override that myself with a custom template, but is that a bug with the default template?  
  > **username_1**: I've updated my answer with a new syntax that works in my tests: `{{ object.checkboxFieldHandle.getOptions()[0].selected == true }}`  
  > **username_2**: This worked! Thank you so much!  
  
  ---
  
  