Field default value specification

__17
Tera Expert

hello

I'm now plagued by the default values for the fields.
For field A, set the string "test" to the default value.

When creating a new record, "test" is entered in field A with a default value.

If field A is set to blank when creating and saving a new record, is it unavoidable to enter the default value "test" instead of blank?
I thought the value displayed on the screen by default when creating a new record was the "default value".

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Sorry what's your challenge?

the default value will be shown when form loads; if user doesn't enter anything the field would have that value shown

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Sorry what's your challenge?

the default value will be shown when form loads; if user doesn't enter anything the field would have that value shown

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Aman Kumar S
Kilo Patron

Hey,

To add to what Ankur mentioned above, if you are creating manually using New button in list layout.

If you want to skip having default value on the form, use initialize() in scripts:

 

initialize() - Creates an empty record suitable for population before an insert.

newRecord() - Creates a GlideRecord, set the default values for the fields and assign a unique id to the record

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar