Every Monday morning, posts who is on leave this week from BambooHR to Slack, with their dates, holidays and work anniversaries.
Uses
BambooHR
Slack
Tell the team who's out this week
showLeaveType to false.Set showLeaveType to false.includeWorkAnniversaries to true.Set includeWorkAnniversaries to true.slackChannelId to blank.Set slackChannelId to blank.today.Get today's date and save it as today.today and save it as weekStart.Get the start of the week for today and save it as weekStart.today and save it as weekEnd.Get the end of the week for today and save it as weekEnd.weekStart readable as “2 Nov” and save it as weekFrom.Make weekStart readable as “2 Nov” and save it as weekFrom.weekEnd readable as “2 Nov” and save it as weekTo.Make weekEnd readable as “2 Nov” and save it as weekTo.entries to an empty list.Set entries to an empty list.nextPage to 1.Set nextPage to 1.morePages to true.Set morePages to true.morePages is yes:While morePages is yes:readErrorIf a step below fails, save the error as readErrorTry
weekStart to weekEnd. Save it as whosOut.List who's out in BambooHR from weekStart to weekEnd. Save it as whosOut.entries and whosOut.entries into one list and save it as entries.Combine entries and whosOut.entries into one list and save it as entries.morePages to whosOut.has_more.Change morePages to whosOut.has_more.On error
readError.message). Check the BambooHR connection under Integrations, then run the workflow again.Stop and report a problem: Nothing was posted: who's out could not be read from BambooHR (readError.message). Check the BambooHR connection under Integrations, then run the workflow again.nextPage.Add 1 to nextPage.entries where item.type in lowercase is holiday and save it as holidays.Keep each item in entries where item.type in lowercase is holiday and save it as holidays.entries where item.type in lowercase is not holiday and save it as absences.Keep each item in entries where item.type in lowercase is not holiday and save it as absences.showLeaveType is yesIf showLeaveType is yesYes
typesErrorIf a step below fails, save the error as typesErrorTry
leaveTypes.List time off types. Save it as leaveTypes.leaveTypes.time_off_types and save it as leaveTypeNames.Rename fields in leaveTypes.time_off_types and save it as leaveTypeNames.absences with leaveTypeNames by timeOffTypeId and save it as absences.Match absences with leaveTypeNames by timeOffTypeId and save it as absences.On error
typesError.message). Check the BambooHR connection, or set showLeaveType to false, then run the workflow again.Stop and report a problem: Nothing was posted: the types of leave could not be read from BambooHR (typesError.message). Check the BambooHR connection, or set showLeaveType to false, then run the workflow again.No
No steps
absences by name, smallest first and save it as absencesByName.Sort absences by name, smallest first and save it as absencesByName.absencesByName by start, smallest first and save it as absencesInOrder.Sort absencesByName by start, smallest first and save it as absencesInOrder.absencesInOrder by employeeId and save it as peopleOut.Group the items in absencesInOrder by employeeId and save it as peopleOut.personLines to an empty list.Set personLines to an empty list.person in peopleOut:For each person in peopleOut:periods to an empty list.Set periods to an empty list.absence in person.items:For each absence in person.items:absence.start readable as “Mon 2 Nov” and save it as period.Make absence.start readable as “Mon 2 Nov” and save it as period.absence.end is not absence.startIf absence.end is not absence.startYes
absence.end readable as “Mon 2 Nov” and save it as absenceLastDay.Make absence.end readable as “Mon 2 Nov” and save it as absenceLastDay.period to period to absenceLastDay.Change period to period to absenceLastDay.No
No steps
absence.leaveType, or if it is empty and save it as leaveTypeName.Use absence.leaveType, or if it is empty and save it as leaveTypeName.leaveTypeName isn't blankIf leaveTypeName isn't blankYes
period to period (leaveTypeName).Change period to period (leaveTypeName).No
No steps
period to the end of periods and save it as periods.Add period to the end of periods and save it as periods.periods with , and save it as periodList.Join periods with , and save it as periodList.person.items[0].name – periodList to the end of personLines and save it as personLines.Add • person.items[0].name – periodList to the end of personLines and save it as personLines.holidays by start, smallest first and save it as holidaysInOrder.Sort holidays by start, smallest first and save it as holidaysInOrder.holidayLines to an empty list.Set holidayLines to an empty list.holiday in holidaysInOrder:For each holiday in holidaysInOrder:holiday.start readable as “Mon 2 Nov” and save it as holidayDates.Make holiday.start readable as “Mon 2 Nov” and save it as holidayDates.holiday.end is not holiday.startIf holiday.end is not holiday.startYes
holiday.end readable as “Mon 2 Nov” and save it as holidayLastDay.Make holiday.end readable as “Mon 2 Nov” and save it as holidayLastDay.holidayDates to holidayDates to holidayLastDay.Change holidayDates to holidayDates to holidayLastDay.No
No steps
holiday.name – holidayDates to the end of holidayLines and save it as holidayLines.Add • holiday.name – holidayDates to the end of holidayLines and save it as holidayLines.anniversaries to an empty list.Set anniversaries to an empty list.anniversaryProblems to an empty list.Set anniversaryProblems to an empty list.showLeaveType is yes and absences isn't empty and the items in absences where…If showLeaveType is yes and absences isn't empty and the items in absences where…Yes
the type of leave was left out because BambooHR did not say which type each absence is. Set showLeaveType to false to post without it. to the end of anniversaryProblems and save it as anniversaryProblems.Add the type of leave was left out because BambooHR did not say which type each absence is. Set showLeaveType to false to post without it. to the end of anniversaryProblems and save it as anniversaryProblems.No
No steps
includeWorkAnniversaries is yesIf includeWorkAnniversaries is yesYes
colleagues to an empty list.Set colleagues to an empty list.datedColleagues to an empty list.Set datedColleagues to an empty list.staffCursor to blank.Set staffCursor to blank.moreStaff to true.Set moreStaff to true.staffErrorIf a step below fails, save the error as staffErrorTry
moreStaff is yes:While moreStaff is yes:staffPage. List employees. Save it as staffPage.colleagues and staffPage.employees into one list and save it as colleagues. Combine colleagues and staffPage.employees into one list and save it as colleagues.staffCursor to staffPage.next_cursor. Change staffCursor to staffPage.next_cursor.moreStaff to staffPage.has_more. Change moreStaff to staffPage.has_more.colleagues where item.hireDate, or if it is empty isn't blank and item.hireDate is not… and save it as datedColleagues.Keep each item in colleagues where item.hireDate, or if it is empty isn't blank and item.hireDate is not… and save it as datedColleagues.colleagues where item._restrictedFields contains hireDate and save it as hiddenHireDates.Keep each item in colleagues where item._restrictedFields contains hireDate and save it as hiddenHireDates.colleagues and save it as activeCount.Count the items in colleagues and save it as activeCount.activeCount is 0If activeCount is 0Yes
work anniversaries were left out because BambooHR returned no active employees. Connect BambooHR with a key from someone who can see everyone's records. to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because BambooHR returned no active employees. Connect BambooHR with a key from someone who can see everyone's records. to the end of anniversaryProblems and save it as anniversaryProblems.Else if @hiddenHireDates isn't empty
hiddenHireDates and save it as hiddenCount.Count the items in hiddenHireDates and save it as hiddenCount.hiddenCount of your activeCount active employees from this connection, so their work anniversaries were left out. Connect BambooHR with a key from someone who can see hire dates, or set includeWorkAnniversaries to false. to the end of anniversaryProblems and save it as anniversaryProblems.Add BambooHR hides the hire date of hiddenCount of your activeCount active employees from this connection, so their work anniversaries were left out. Connect BambooHR with a key from someone who can see hire dates, or set includeWorkAnniversaries to false. to the end of anniversaryProblems and save it as anniversaryProblems.Else if @datedColleagues is empty
activeCount active employees has a hire date in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because none of your activeCount active employees has a hire date in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Otherwise
No steps
On error
datedColleagues to an empty list.Change datedColleagues to an empty list.staffError.message). to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because the employee list could not be read from BambooHR (staffError.message). to the end of anniversaryProblems and save it as anniversaryProblems.unreadableHireDates to an empty list.Set unreadableHireDates to an empty list.colleague in datedColleagues:For each colleague in datedColleagues:dateError If a step below fails, save the error as dateErrorTry
colleague.hireDate to weekEnd and save it as yearsBySunday.Count the years from colleague.hireDate to weekEnd and save it as yearsBySunday.yearsBySunday is greater than or equal to 1If yearsBySunday is greater than or equal to 1Yes
colleague.hireDate by yearsBySunday years and save it as anniversaryDate.Move colleague.hireDate by yearsBySunday years and save it as anniversaryDate.weekStart and anniversaryDate in days is greater than…If the difference between weekStart and anniversaryDate in days is greater than…Yes
colleague.displayName, or colleague.firstName colleague.lastName if it is empty and save it as colleagueName.Use colleague.displayName, or colleague.firstName colleague.lastName if it is empty and save it as colleagueName.anniversaryDate and save it as anniversaryDay.Get the day of the week for anniversaryDate and save it as anniversaryDay.yearsText to yearsBySunday years.Set yearsText to yearsBySunday years.yearsBySunday is 1If yearsBySunday is 1Yes
yearsText to 1 year.Change yearsText to 1 year.No
No steps
anniversaries and save it as anniversaries.Add a record of date and line to the end of anniversaries and save it as anniversaries.No
No steps
No
No steps
On error
colleague.displayName to the end of unreadableHireDates and save it as unreadableHireDates.Add colleague.displayName to the end of unreadableHireDates and save it as unreadableHireDates.unreadableHireDates isn't emptyIf unreadableHireDates isn't emptyYes
unreadableHireDates with , and save it as unreadableNames.Join unreadableHireDates with , and save it as unreadableNames.unreadableNames could not be read, so their work anniversaries were left out. Correct it in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Add the hire date of unreadableNames could not be read, so their work anniversaries were left out. Correct it in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.No
No steps
No
No steps
anniversaries by date, smallest first and save it as anniversariesInOrder.Sort anniversaries by date, smallest first and save it as anniversariesInOrder.line from every item in anniversariesInOrder and save it as anniversaryLines.Get line from every item in anniversariesInOrder and save it as anniversaryLines.peopleOut and save it as peopleCount.Count the items in peopleOut and save it as peopleCount.outSummary to peopleCount people.Set outSummary to peopleCount people.peopleCount is 0If peopleCount is 0Yes
outSummary to nobody has time off booked.Change outSummary to nobody has time off booked.Else if @peopleCount is 1
outSummary to 1 person.Change outSummary to 1 person.Otherwise
No steps
peopleSection to blank.Set peopleSection to blank.peopleCount is greater than 0If peopleCount is greater than 0Yes
personLines with a new line and save it as personList.Join personLines with a new line and save it as personList.peopleSection to Change peopleSection to
personList.No
No steps
holidaySection to blank.Set holidaySection to blank.holidayLines isn't emptyIf holidayLines isn't emptyYes
holidayLines with a new line and save it as holidayList.Join holidayLines with a new line and save it as holidayList.holidaySection to Change holidaySection to
*Holidays*
holidayList.No
No steps
anniversarySection to blank.Set anniversarySection to blank.anniversaryLines isn't emptyIf anniversaryLines isn't emptyYes
anniversaryLines with a new line and save it as anniversaryList.Join anniversaryLines with a new line and save it as anniversaryList.anniversarySection to Change anniversarySection to
*Work anniversaries*
anniversaryList.No
No steps
postErrorIf a step below fails, save the error as postErrorTry
slackChannelId. Save it as posted.Send a message to slackChannelId. Save it as posted.*Who's out this week (weekFrom – weekTo):* outSummary@peopleSection@holidaySection@anniversarySectionOn error
postError.message). Check that 'slackChannelId' at the top of the workflow is your team channel's ID, and for a private channel add the Lodol app to it by typing /invite Lodol in that channel.Stop and report a problem: The message could not be posted to Slack (postError.message). Check that 'slackChannelId' at the top of the workflow is your team channel's ID, and for a private channel add the Lodol app to it by typing /invite Lodol in that channel.holidayLines and save it as holidayCount.Count the items in holidayLines and save it as holidayCount.anniversaryLines and save it as anniversaryCount.Count the items in anniversaryLines and save it as anniversaryCount.anniversaryProblems isn't emptyIf anniversaryProblems isn't emptyYes
anniversaryProblems with Also, and save it as problemList.Join anniversaryProblems with Also, and save it as problemList.weekFrom – weekTo (outSummary), but problemList.Stop and report a problem: Posted who's out for weekFrom – weekTo (outSummary), but problemList.No
No steps
weekFrom – weekTo: outSummary; holidays: holidayCount; work anniversaries: anniversaryCount.Finish the run: Posted who's out for weekFrom – weekTo: outSummary; holidays: holidayCount; work anniversaries: anniversaryCount.