0

Code to generates a virtual agent greeting message based on the time of day ServiceNow(Good Morning, Good Afternoon , Good Evening)

(function execute() {
var getime = new GlideDateTime().getLocalTime().getByFormat('HH');
 var answer = 'Hello';
if(getime < 12) {
answer = 'Good Morning';
} else if(getime >=12 && getime < 18) {
answer = 'Good Afternoon';
} else if(getime >= 18) {
answer = 'Good Evening';
}
 return answer + ' ' + vaInputs.user.first_name;
})()

Code to generates a virtual agent greeting message based on the time of day ServiceNow
Working Code Edited question April 9, 2024