When ever any agreement of the Customer or Client reaches 90 days to expiration

maheshch18
Tera Contributor

Hi Team,

 

In 90 days an agreement was expired, and how to send automatic email notifications to the users (before expiration).

 

Regards,

Mahesh.

4 REPLIES 4

Community Alums
Not applicable

Hi @maheshch18 ,

 

You can write a scheduled job and run it on daily basis. You will need to check the expiration date of these agreements and trigger notification using gs.eventQueue() method.

 

Thanks,

Kanhaiya

Hi Kanhaiya,

 

I have tried the below code in the scheduled job.

 

var currentDate = new GlideDate();
currentDate.addDaysUTC(90);
var ed=currentDate.getDate();
var gr = new GlideRecord('sn_customerservice_agreement');
gr.addQuery('u_end_date',ed);
gr.query();
while(gr.next()){
gs.eventQueue('sn_customerservice.Agreement Expiration',gr,'','');
gr.update();
}

 

But It's not working fine.

 

Regards,

Mahesh.

Community Alums
Not applicable

Hi @maheshch18,

 

You cad do as per below example -

FirstJob(); // To fetch agreements which will be expired after 30 days

SecondJob(); //to fetch agreements which will be expired after 60 days

 

function FirstJob()

{

  var gr = new GlideRecord('table_name');

  gr.addEncodedQuery('expiration_dateRELATIVEEE@dayofweek@ahead@30');

  gr.query();

  while(gr.next()){

  gs.eventQueue("expire.reminder",gr,30);

  }

}

 

function SecondJob()

{

  var gr = new GlideRecord('table_name');

  gr.addEncodedQuery('expiration_dateRELATIVEEE@dayofweek@ahead@60');

  gr.query();

  while (gr.next()){

  gs.eventQueue("expire.reminder",gr,60);

  }

 

You may modify the days in condition.

 

Hope it helps, Please mark may solution as correct if you find it helpful.

 

Thanks,

kanhaiya

Hi Kanhaiya,

 

I need to update the notification template like the below:

 

Subject:

The agreement is reaching expiration in << Days Left to Expire >> Days 

 

Body:

Hi Team,

The below Agreement will be expiring in <<Days left to expire>> days.

Account Name: <<company name >>

Agreement Name: << Agreement Label Name >>

End date of Agreement: << End date of Agreement >>

AT&T Engagement Manager: << pull the name from Relationship>>

 

Please provide the solution on how to get the above details.

 

Regards,

Mahesh