Email Notification to trigger on every 30 and 60 Days based on Software Entitlement End Date.

VasanthMuthuram
Tera Contributor

Notification to trigger on every 30 and 60 Days based on Software Entitlement End Date from today.

 

alm_license_list : All the Entitlements has an End date.

https://www.servicenow.com/community/developer-articles/fire-an-email-notification-from-a-schedule-j...

I followed the steps as per the link above and using the below Scheduled Job Code the Notification is triggering.

Requirement :: I need 2 Notification emails to trigger for 30 days and 60 days, Once a Month. How to do ?

 

var gr = new GlideRecord('alm_license');
gr.addEncodedQuery('install_status=1^end_dateISNOTEMPTY^end_dateRELATIVELT@month@ahead@1');
gr.query(); 
while (gr.next()) {
gs.eventQueue("Softwarentitlement.expiry", gr);
}

 

5 REPLIES 5

johnfeist
Mega Sage
Mega Sage

Hi Vasanth,

 

You will need to have two jobs, one for thirty days and one for sixty days.  The two job setups will look similar.  The one thing that you will need to change is that for the thirty day one the criteria should be checking the end date between thirty and fifty nine days.  Otherwise users will get two emails since by definition anythng that is sixty days is also thirty days.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Hello John,

I have created 2 events, 2 scheduled Jobs & 2 Notifications for 30 & 60days. its work perfectly fine.

But if there are 5 records in the alm_licence table with the end date within 30 days, then 5 mails are getting triggered. The clients wants 1 mail for 30 days and 1 mail for 60 days.

Hi Vasanth,

 

If you need to have one email listing the five rows of data, what you need to do is have a mail script as part of your notification.  Then when you fire the event, you can pass any necessary information in the parms which the mail script can pick up.  From there, the script will insert the data rows into the email.

 

If you just need to send the number, then have that number as one of the parms which can be directly accessed in the notification setup.

 

If you need to send both emails even if they have no data, I'd suggest setting up separate notifications and triggering events.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

VasanthMuthuram
Tera Contributor

Requirement ::  Each record has different End dates.  Each records has to trigger a mail notification for 30 days / 60 days / 0 Days from the End date.

 

Display nameEnd dateToday dateCount of days from todayNotification Trigger condition for 0 daysNotification Trigger condition for 30 daysNotification Trigger condition for 60 days
DbVis Software AB DbVisualizer 23.x Pro English26-05-202426-04-202430.00 26-04-2024 
JetBrains IntelliJ IDEA Business29-05-202426-04-202433.00 23-04-2024 
try to show the name - Altova XMLSpy Professional26-04-202426-04-20240.0026-04-2024  
ETST SOFTWARE 201-07-202426-04-202466.00  20-04-2024
TEST SOFTWARE 502-08-202403-06-202460.00  03-06-2024

I need help in scripting.

var gr = new GlideRecord('alm_license');
gr.addEncodedQuery('end_dateISNOTEMPTY^install_status=1^end_dateRELATIVELT@dayofweek@ahead@30');
gr.query(); 
while (gr.next()) {
gs.eventQueue("Softwarentitlement.expiry 30", gr);
}