---
sourceDocument: Yokohama Build or modify applications
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/yokohama/application-development

 Release :

    - yokohama

ft:locale :

    - en-US

ft:publication_title :

    - Yokohama Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# Tutorial part 6: Add date validation using code generation

# Tutorial part 6: Add date validation using code generation {#ariaid-title1}

* Release version: Yokohama
* 
* Updated January 30, 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Currently, there is no validation for date fields in event records, allowing events to be created with a start date after the end date. This section shows how to use code generation to create a business rule preventing this
issue. While date validations can be time-consuming, Now Assist streamlines the process with code generation.

## Before you begin

Role required: admin or delegated_developer

## Procedure

1. From the We Volunteer app dashboard, select CreateFile.
2. Enter Global in the Application field.
3. Under the Server Development category, select Business Rule.
4. Select Continue.
5. Add the following specifications to the new business rule:  
   * Name: Date validation
   * Table: Event \[x_snc_we_volunteer\]
   * Advanced: true (select the check box)
   * When: before
   * Insert: true (select the check box)
   * Update: true (select the check box)
   {#lab-6-add-date-validation-using-code-gen__ul_awr_y2q_c2c}
6. Select Add Filter Condition.
7. Add the following specifications to the filter condition:  
   * Starts: changes
   * OR
   * Ends: changes
   {#lab-6-add-date-validation-using-code-gen__ul_ofz_2fq_c2c}
8. On the Advanced tab, click into the third line in the script editor.
9. Open the Now Assist code generator by pressing Command + Enter (on Mac) or Ctrl + Enter (on Windows).
10. Enter the following text: <kbd class="ph userinput">Get value of start date(starts) &amp; end date (ends) from the current record, using GlideDateTime() check if start date is greater than end date, abort if true, check if start date is past due, abort if true</kbd>.
11. Select the Submit icon (![submit icon]()) and wait a few moments for Now Assist to generate a code snippet.
12. Select Accept.
13. Select Submit.

*[\>]: and then


