- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 12:58 AM
In existing user table i added date of birth for users and now i have to create dashboard for upcoming birthday list and every year it need to show how can i acheive this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 01:59 AM
Sure thing!
Write a business rule, as below:
And as script, write something like this:
(function executeRule(current, previous /*null when async*/) {
var nextBirthday = new GlideDateTime(current.getValue('u_birth_date')); // change field name to your custom field name
while(nextBirthday.before(new GlideDateTime())){
nextBirthday.addYears(1);
}
current.setValue('u_next_birthday', nextBirthday); // change field name to your custom field name
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 11:32 AM - edited 07-26-2023 11:36 AM
I prefer Flow designer over scheduled job, but you can go with either one.
No condition should be needed on the trigger, other than it should run yearly on the first day of the new year.
Adding a simple example below, using Flow designer.
Providing some explanation of some of the steps in the Flow below, first step 1
Step 3
Step 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 01:46 AM
hi olaN ,
thanks for this, currently am working on option no 2 i acheived this calculation logic through client script but i want to do this in business rule could you help me?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 01:59 AM
Sure thing!
Write a business rule, as below:
And as script, write something like this:
(function executeRule(current, previous /*null when async*/) {
var nextBirthday = new GlideDateTime(current.getValue('u_birth_date')); // change field name to your custom field name
while(nextBirthday.before(new GlideDateTime())){
nextBirthday.addYears(1);
}
current.setValue('u_next_birthday', nextBirthday); // change field name to your custom field name
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 04:47 AM
Thanks olaN, its working fine
and why we using this line -
while(nextBirthday.before(new GlideDateTime()))}
and what is the condition i want to give in scheduled job?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 11:01 AM
The while loop is there to make sure the correct date is set.
For example, if birthdate is 2018-03-01, then the logic will run as follows.
add another year to the variable, so it will become 2019-03-01, then do another compare in the while condition (the date is still less than (before) todays date (which is returned from new GlideDateTime()).
So the loop continues, and sets the variable to 2020-03-01, 2021-03-01, 2022-03-01, 2023-03-01, and finally 2024-03-01.
Then the condition of the while loop fails (because now the date is after today's date), and the date is set as next birthday date.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 11:32 AM - edited 07-26-2023 11:36 AM
I prefer Flow designer over scheduled job, but you can go with either one.
No condition should be needed on the trigger, other than it should run yearly on the first day of the new year.
Adding a simple example below, using Flow designer.
Providing some explanation of some of the steps in the Flow below, first step 1
Step 3
Step 5