Skip to tutorial content
Rate module Not yet rated

Default Values

2 min read
On this page

In this lesson, you will learn:

  • What a default value is
  • How to set a fixed default and a script default
  • When default values are applied

1 A head start on every form

When you open a new incident, some fields are already filled in: State is New, Opened is right now, and Opened by is you. That’s because they have default values. They save time and reduce mistakes. ⏱️

Key term: Default value

The value a field starts with on a new record. It’s set in the Default value field of the dictionary entry.

2 Two kinds of defaults

Kind What you enter Example
Fixed A plain value 3 for Impact = 3 – Low
Script Starts with javascript: javascript:gs.getUserID() for the current user
A new Room Booking form with default values filled in. Marker 1: Opened by is set to the logged-in user with javascript:gs.getUserID(). Marker 2: Booking date is set to today with javascript:gs.now(). Marker 3: State is Open, a fixed value. Marker 4: Attendees is 1, a fixed value. The other fields are empty.
Figure 1. Defaults fill in a new record so people type less.

3 Handy script defaults

Default value Gives you
javascript:gs.getUserID() The sys_id of the logged-in user (for reference fields to User)
javascript:gs.nowDateTime() The current date and time (for Date/Time fields)
javascript:gs.now() Today’s date (for Date fields)

πŸ’‘ Good to know: For a reference field with a fixed default, like a group, enter the group’s sys_id, not its name.

4 When defaults apply

  • When a new form opens, the default is filled in. The user can still change it.
  • When a record is inserted by a script or import and the field is empty, the default is used.
  • Defaults never change existing records.

πŸ“ Note: Need a different default on one child table? Use a dictionary override (Lesson 30.3).

⭐ Remember: Default value = starting value for new records. Plain value or javascript:.

5 Let’s try it: set two defaults

  1. Open a Room Booking. Right-click Attendees and choose Configure Dictionary. Set Default value to 1. Update.
  2. Right-click Booking date, open its dictionary, and set Default value to javascript:gs.now(). Update.
  3. Create a new Room Booking. Are Attendees and Booking date filled in?
  4. Open an old Room Booking. Did its values change? (They shouldn’t!)

6 Quick recap

  • A default value fills in a field on new records
  • It can be a fixed value or a javascript: script
  • gs.getUserID() gives the current user. gs.now() and gs.nowDateTime() give today and now
  • Defaults never change existing records

7 Check yourself

Think of your answer first. Then tap to check.

1 Where do you set a field’s default value? Show answer

In the Default value field of its dictionary entry.

2 Which default fills a User reference field with the logged-in user? Show answer

javascript:gs.getUserID()

3 You add a default to a field. Do old records get it? Show answer

No. Defaults only apply to new records.

Nice work! You finished this lesson. πŸŽ‰

Was this lesson helpful?

Have a question or doubt?

Ask here and get help from instructors and fellow learners.

0 / 300

Only logged-in learners can post.