- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 08:22 AM
Hello,
I want to add an alert message to users on top of the form when they click 'New' to create a new incident to 'attach a document'. Is this possible via UI Macro or any other way? I do not want it to be a hard stop, the user is still able to 'submit/save' the record, and move on to the next state.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 08:27 AM
Something like this... untested code ahead:
function onLoad() {
if (g_form.isNewRecord()) {
g_form.addInfoMessage('Please attach a file. Thank you.');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 08:26 AM
You could use an onLoad client script that checks if this is a new record using g_form.isNewRecord(); If so, use g_form.addInfoMessage()
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 08:27 AM
Something like this... untested code ahead:
function onLoad() {
if (g_form.isNewRecord()) {
g_form.addInfoMessage('Please attach a file. Thank you.');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 09:10 AM
Thank you! That did the trick!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2016 08:27 AM
The best way is to create a display business rule:
- Create a new business rule and set name to something that makes sense to you.
- Check advanced checkbox
- Set When to display.
- Click the advanced tab and enter the following script:
(function executeRule(current, previous /*null when async*/) {
if (current.isNewRecord()) {
gs.addInfoMessage("Please be sure to attach a document.");
}
})(current, previous);
Then save the record and test.