
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2021 09:22 PM
How to set default value via gs.getProperty(), and set the value on field on the form when field have "null" value.
For example , "Email User Name" field on the incident form.
I have created sys_property with sys_id ,now client required whenever field "Email User Name" will be blank /Null, then set the system property .
Thanks,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2021 09:54 PM
Hi there,
Do you mean like you are applying gs.getProperty('some_property'), this actually does not exist or is null, so you would like a default value instead?
You can use:
var x = gs.getProperty('some_property') || 'Your default value';
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2021 09:54 PM
Hi there,
Do you mean like you are applying gs.getProperty('some_property'), this actually does not exist or is null, so you would like a default value instead?
You can use:
var x = gs.getProperty('some_property') || 'Your default value';
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2021 10:02 PM
There is field on scoped application HRSM ,HR CHANGE there is field name "Email Name User " field .
I have created system property which contain sys_id .
Now ,
If "Email Name User" if blank then, it will set to the "system property" .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2021 10:18 PM
You will have to use either default value in the field dictionary or before insert BR
BR Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
// give valid field name here
if(current.email_user_name == ''){
current.email_user_name = gs.getProperty('property_name');
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 07:36 AM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
If not, please let us know if you need some more assistance.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader