- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2025 11:48 PM
(function calculatedFieldValue(current) {
// if current GlideRecord is new record
if (current.isNewRecord()) {
// the field value = INV_sysuserName
var createName = "INV_" + gs.getUserName().toUpperCase();
return (createName); // return the calculated value
} else {
var userName = "INV_" + current.getValue('sys_created_by').toUpperCase();
return (userName); // return the calculated value
}
})(current);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 12:01 AM
Hi,
A calculated value in ServiceNow is exactly that. It's calculated whenever a record is shown, in a list or on a form for example. Therefore must be used with caution, because it can have severe impact on your instance performance.
If your aim is to set the value of a field at creation-time of a record, I would suggest that you either implement a business rule, that runs on insert, and has the same script, just add a line to set the value to the correct field.
Or you can try setting the value as a default value on the dictionary entry.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 12:01 AM
Hi,
A calculated value in ServiceNow is exactly that. It's calculated whenever a record is shown, in a list or on a form for example. Therefore must be used with caution, because it can have severe impact on your instance performance.
If your aim is to set the value of a field at creation-time of a record, I would suggest that you either implement a business rule, that runs on insert, and has the same script, just add a line to set the value to the correct field.
Or you can try setting the value as a default value on the dictionary entry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 01:27 AM
Hi OlaN,
Thanks for the advise, I put the script in the default value and it functioned as desired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 12:02 AM
Hi @cindy_huang
You need to use a 'Before Insert' business rule to automatically populate the field value.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2025 01:25 AM
Hi Siva,
Thanks for the advice. The before insert is a good way, but it does not populate value before the user click submit which the client required. I tried putting the script in the default value and it went well. I will adapt the BR method in another field that is read-only and is not required to display before creating.