I have to calculate years of working.

niveditakumari
Mega Sage

Hi @shivatmika_19

 

I have written code and added below code to calculate years. 

It is not working. 

Please find attached screenshot : 

 

niveditakumari_2-1740941280843.png

 

niveditakumari_1-1740941167146.png

 

niveditakumari_0-1740941098056.png

 

Please help me to correct that. 

 

Regards, 

Nivedita 

 

 

2 ACCEPTED SOLUTIONS

@niveditakumari 
Please use the following content: 

Congratulations on ${mail_script:yearsOfWorking} Amazing Years, ${first_name} ${last_name}

Dear ${first_name} ${last_name},

Today marks a special milestone for ${first_name} ${last_name}'s ${mail_script:yearsOfWorking}-year work anniversary at ACME South America! Over the years, ${first_name} ${last_name} has consistently contributed their qualities/skills to our team.

From leading successful projects in department Product Management to mentoring new team members, ${first_name} ${last_name} has been an invaluable part of our journey." Your commitment and hard work have made a lasting impact, and we're so grateful to have you as part of our ACME South America family.

Let's all take a moment to congratulate ${first_name} ${last_name} and celebrate their incredible journey with us. Here's to many more successful years together!

Thank you for being an inspiration and for all the contributions you've made. Happy Work Anniversary, ${first_name} ${last_name}!

Signature:

Aruna,

Human Resource Manager.

I believe I've addressed all of your questions. If you're satisfied with the solution, kindly click the thumbs up and accept my answer to close this thread.

 

 

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

View solution in original post

@niveditakumari 

If you are using DateTime field please adjust the script as follow:

var hiringDate = current.u_hr_hire_date;
var hiringDateGd = new GlideDateTime(hiringDate);
var currentDateGd = new GlideDateTime();
var hiringYear = hiringDateGd.getYearUTC();
var currentYear = currentDateGd.getYearUTC();
var experience = currentYear - hiringYear;
template.print(experience);

If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

View solution in original post

29 REPLIES 29

Hi @niveditakumari,

Was this helpful?


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

Hi @Medi C

 

I have tried with your approach but it is not working. 

niveditakumari_0-1742113275685.png

 

niveditakumari_1-1742113365847.png

 

I have tried with other approach and it is working as expected but it is showing that content in subject and in email content as well and I only want that in subject. 

niveditakumari_2-1742113621035.png

 

Can you please help me to correct that. 

 

Regards, 

Nivedita 

 

 

 

 

Hi @Medi C

 

Can you please me how to add email script in notification subject. 

 

Regards, 

Nivedita 

 

 

 

 

HI @Medi C

 

I have accepted your solution but I'm having error while testing that. 

I'm executing my schedule job now and I'm able to see that in email logs it is sending email notification for user whom hire date is on 17th March ideally it should send notification to user whom hire date is on today 16th March but it is taking that user whom hire date is on tomorrow that is 17 March and sending notification to that user. I need to send notification to user when their anniversary date is completed and we are calculating anniversary date based on hire date and it should send notification user whom hire date is on today. 

I have written script : 

1. Schedule job 

niveditakumari_0-1742119181914.png 

 

2. Email script : 

niveditakumari_1-1742119337285.png

 

 

It is taking for next day.

Can you please help me to correct that and it send notification to user whom hire date is on today only. 

 

Regards, 

Nivedita 

 

 

 

niveditakumari
Mega Sage

Hi @Medi C

 

Thank you for all your help. 

It is working as expected. 

 

Regards, 

Nivedita