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

Hi Vasanth,

 

What you have set up will cause an email to be sent for every license.  As you indicated in an earlier reply, you need to send two emails, one for over thirty and one for over sixty.  If all you need is an email that says "we have 9 licenses over thirty days" (or words to that effect) then you need to use a glide aggregate or include something like this:

gr.query();
var grCount = gr.getRowCount();
gs.eventQueue("Softwareentitlement.expiry 30", gr, grCount);

In your notification, you just need to include ${event.parm1) wherever you need to include the number.

 

If you need to list the expires then you'll need the mail script I mentioned in an earlier post.  In there, you'll just recreate the query that you have.  From there, you just iterate through the result set adding each row to the notification.

 

var gr = new GlideRecord('alm_license');
gr.addEncodedQuery('end_dateISNOTEMPTY^install_status=1^end_dateRELATIVELT@dayofweek@ahead@30');
gr.query(); 
while (gr.next()) {
   template.print(<format the line to go into the email>);
}

You may need to do some lookups or other things as part of setting up the string that will be added to the email.

 

Hope that helps.

:{)

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