Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Email Notification that Account is getting expired

NiKhil70
Kilo Guru

Hi ,

I have a Requirement to send an email Notification to the Requester  when the end date of Contractor is getting close .

In detail :

In On-boarding REQUEST form , we have ( Start date & end date ).

If the Employee type is Contractor then we should enter the End date which is Mandatory .

I have entered  (start date = Jan 1 , 2019 )& (End Date is June 30 , 2019) while submitting an on boarding Request for user "XYZ"

Requester should get Email Notification that user ( "XYZ") account is coming up for expiration on May 30 , June 15 ( Nothing but 30 days & 15 Days before Expiration )

How can i achieve this ?

Require Inputs to proceed further .

 

Thanks

NR.

1 ACCEPTED SOLUTION

Hi Naveen ,

Thanks for providing inputs , i made some changes to your script and Added some functions , its working correct .

PLease find the Below Code :

 

var newexp=gs.dateGenerate(SS.variables.End_date,'00:00:00'); // End_date is variable name

var gdt= new GlideDateTime(newexp);

var sjb= gs.dateGenerate(gs.now(),'00:00:00');

var gdt1= new GlideDateTime(sjb);

gdt1.addDays(30);

if(gdt.getDate().toString()==gdt1.getDate().toString())

{

//gs.log("RITM NUMBER IS " +SS.number);

                gs.eventQueue('Alert check',SS,gs.getUser(),SS.variables.ob_hire_report_to);

gs.log("end count of RITM is " +SS.number);       

}

}

}

THanks

NR

View solution in original post

11 REPLIES 11

Hi ,

 

where we have to write these script please tell me?

Hi preddy,

You have to create a scheduled job and run it as per your requirement .

Copy and paste the below code in Scheduled job .

create a email notification when event is fired .

It will send out if any user end date is with in the Time interval 3,7,15,30 days.

Thanks

NR

Click on Helpful if you are satisfied with my answer .