- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2014 06:21 AM
Through our LDAP connection all accounts created in AD are instantly created in ServiceNow. I had planned to leverage this process to send a kind of "Welcome" email to all new employees/students as they are added to the sys_user table, but I've hit a snag because even though their AD usernames are created their actual email addresses aren't created until midnight when a report is run somewhere by the AD admin and it creates an email account and attaches it to their username.
So what I need to do now is schedule something that checks for newly created accounts in the sys_user table and sends this "Welcome" email at like 4am everyday. I assume it needs to be done maybe through the event registry and the system scheduler, but I really haven't messed with those to features at all so I need some help...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2014 08:20 AM
This is what I would do:
1. create a new "Welcome email sent" True/False field on the User table
2. set the new field to "True" or checked for all your current users
3. create a new Event called "u_send.welcome.email"
4. create a new Scheduled Job (System Definition \ Scheduled Jobs) and select "Automatically run a script of your choosing" in order to create a new "Scheduled Script Execution" record. Set it to run when you want it to.
Script for the Scheduled Job:
(function() {
var gr = new GlideRecord("sys_user");
gr.addEncodedQuery("active=true^emailISNOTEMPTY^u_welcome_email_sent=false");
gr.query();
while (gr.next()) {
gs.eventQueue("u_send.welcome.email", gr);
gr.u_welcome_email_sent = true;
gr.update();
}
})();
That way you don't have to worry about when the record was created and you can easily tell with the new field if the email was sent or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2014 09:00 AM
Absolutely, if you wanted to do that as the email addresses come in.