Birthday and/or Anniversary Campaigns

JD Barlow
Tera Guru

I am trying to create a campaign to show a banner on the portal and send an email to employees on their birthdays. I know this is possible because it seems to be included in most demos that I have seen. What I haven't figured out is how to actually create the campaign to have it check if someone's birthday is today. I tried creating an audience with a condition on the birthday, but there doesn't seem to be an option to compare the birthday to the current month and day. Can someone help guide me in the right direction on this? I am assuming the same logic would be used for work anniversaries as well.

11 REPLIES 11

Hi,

With this you setup an all active user as audience as starting point right and have it evaluated on a freq method.. 

mandle
Mega Guru

Allison is spot on. I created a User Criteria that effectively compared today's month and today's date to the month and date of all HR Profiles to determine if today is the currently logged in user's birthday. Then I remembered that "advanced" (scripted) User Criteria cannot be used for Audience records. 

For the "Happy Birthday" and the "Happy Work Anniversary" portal content you could just use 2 instances of Content Delivery widgets like Styled Content. Place them both on say the homepage and use User Criteria applied to each Widget Instance. Then just use the rolling Content Automation to handle the email notifications. 

Hi, do you have anything to show how you have configure this script? I want to avoid to build 50 Campaing bundles, for each year that a person can be its birthday. Just to say, happy birth. 

atherakhtar
ServiceNow Employee
ServiceNow Employee

Hello @Allison French ,

I used a boolean field which would be set to true or false on my HR Profile if the birthday is today or not.

I put this below script in a scheduled job.

var nowDate = new GlideDate();

var Tday=parseInt(nowDate.getDayOfMonthNoTZ(),10);
var TM=nowDate.getMonthNoTZ();
var Final=Tday+"-"+TM;
var grU = new GlideRecord('sn_hr_core_profile');
grU.addEncodedQuery("date_of_birthISNOTEMPTY");
grU.query();
while(grU.next())
{
var BirthDate = grU.date_of_birth;
var BDay=parseInt(BirthDate.split("-")[2],10);
var BMonth=parseInt(BirthDate.split("-")[1],10);
var FinalBday=BDay+"-"+BMonth;
if(Final == FinalBday)
{

grU.u_isbirthdaytoday = 'true';
grU.update();
}
else if(Final != FinalBday){
grU.u_isbirthdaytoday = 'false';
grU.update();
}

}

Then this field u_isbirthdaytoday will be used in the audience of the campaign to show birthday messages to users who have birthdays today.

The same script can be leveraged in any other server script based on the situation.

For me running it every day at midnight sufficed the customer requirement.

Please mark this as helpful/correct answer to help others on the community.

Regards,

Ather

 

 

 

Greetings @atherakhtar !

Thanks for sharing your script! We have a business requirement to show the birthday banner three days before and after FinalBday. I tried subtracting two glide dates but my syntax might be off. Any assistance is greatly appreciated. Thanks!

var nowDate = new GlideDate();

var Tday = parseInt(nowDate.getDayOfMonthNoTZ(), 10);
var TM = nowDate.getMonthNoTZ();
var Tyear = nowDate.getYearNoTZ();
var Final = new GlideDate();
Final.setDisplayValue("Tyear" + "-" + TM + "-" + Tday);

var grU = new GlideRecord('sn_hr_core_profile');
grU.addEncodedQuery("date_of_birthISNOTEMPTY");
grU.query();

while (grU.next()) {

    var BirthDate = grU.date_of_birth;
    var BDay = parseInt(BirthDate.split("-")[2], 10);
    var BMonth = parseInt(BirthDate.split("-")[1], 10);
    var FinalBday = new GlideDate();
    FinalBday.setDisplayValue("Tyear" + "-" + BMonth + "-" + BDay);

    var dur1 = GlideDate.subtract(FinalBday, Final);
    var dur1diff = dur1();

    if (dur1diff <= 3) {
        grU.u_isbirthdaytoday = 'true';
        grU.update();
        
    } else {

        grU.u_isbirthdaytoday = 'false';
        grU.update();
    }

}

 

-Benjie