Adding a alert message

brown9394
Tera Expert

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.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Something like this... untested code ahead:



function onLoad() {


        if (g_form.isNewRecord()) {


                  g_form.addInfoMessage('Please attach a file. Thank you.');


        }


}


View solution in original post

8 REPLIES 8

Chuck Tomasi
Tera Patron

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


Chuck Tomasi
Tera Patron

Something like this... untested code ahead:



function onLoad() {


        if (g_form.isNewRecord()) {


                  g_form.addInfoMessage('Please attach a file. Thank you.');


        }


}


Thank you! That did the trick!


Michael Ritchie
ServiceNow Employee
ServiceNow Employee

The best way is to create a display business rule:


  1. Create a new business rule and set name to something that makes sense to you.
  2. Check advanced checkbox
  3. Set When to display.
  4. 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.