Put a warning message on record producer

dfry123
Mega Expert

Is there a way to put a warning message on a record producer (Either when first going to the form or after submitting) that only shows up after a certain time?

I need to put a warning up that shows up only during the hours of 5 PM - 8 AM.

Thank You!

1 ACCEPTED SOLUTION

rob_pastore
ServiceNow Employee
ServiceNow Employee

oops, i think i screwed you up earlier.  



looking at the error it says that it doesn't recognize the function isInSchedule('string') - becasue that function requires a date object not a string.   i told you getNow would be an object and that's where i messed you up.



put this back in



var schedTime = new GlideDateTime(gs.nowDateTime());      


View solution in original post

28 REPLIES 28

rob_pastore
ServiceNow Employee
ServiceNow Employee

I wouldn't do this with a client script - client side treats dates different (as a string) then server side (as an object).



If you keep it in the record producer script, it should act as an on submit.



The gs.log will be in System Logs > All.   The message will start with "Time 1:"


In the logs I found this:



org.mozilla.javascript.EcmaError: "CalculateTime" is not defined.
    Caused by error in Business Rule: 'Calculate Time 2' at line 1


==>     1: CalculateTime();


I also found this which I think is the issue.....



find_real_file.png


dfry123
Mega Expert

Yes, you are right.. I just tested this on a machine on the west coast and it doesn't prompt at the current time like it is on the east coast. I tried putting the same script in the record producer script... but it does nothing:



function onSubmit() {


  var today = new Date().getHours(); //compare in 24h


  if (today >= 8 && today <= 14) { //8AM-5PM




  } else {



  alert('After Hours');


  }


}


rob_pastore
ServiceNow Employee
ServiceNow Employee

can you post the full script?   We are probably mixing client side functions that won't work on the server side (like alert())