In this sample, we will show you how to post birthday wishes to Microsoft Teams from B1 Print and Delivery.
What you need:
- B1 Usability Package 2019.04 or higher
- A B1 Usability Package License
- A B1 Print and Delivery License
- A Microsoft Teams account (you need to be owner/admin of the Channel you set it up in)
- An incoming Webhook connector (See this video on how to make one)
- An empty dummy crystal report
Step by Step Setup:
- Go to Administration > Add-ons > B1 Usability Package > Module Configuration > B1 Print and Delivery > Mass Delivery Configuration
- Create the following Custom Configuration
- SQL for Copy/Paste
DECLARE @Month INT = (SELECT MONTH(GETDATE()));
DECLARE @Day INT = (SELECT DAY(GETDATE()))
SELECT T0.empId FROM OHEM T0
WHERE T0.Active = 'Y'
AND ISNULL(T0.termDate,'30001231') > GETDATE()
AND MONTH(T0.birthDate) = @Month
AND DAY(T0.birthDate) = @Day
- Go to Administration > Add-ons > B1 Usability Package > Module Configuration > B1 Print and Delivery > Crystal Report Definition
- Create the following configuration (the path to the Crystal report need to be to your empty Crystal Report)
- Go to Administration > Add-ons > B1 Usability Package > Module Configuration > B1 Print and Delivery > Report Action
- Create a new Report action of type "HTTP Trigger"
-
- In name write "Birthday Bot"
- In URL enter the URL of you Microsoft Teams Webhook
- Set template to "Microsoft Teams"
- Leave Subject blank (not used in this sample)
- Enter the following message
SQL(
SELECT
CASE WHEN T1.Name IS NULL THEN
CASE T0.sex
WHEN 'M' THEN 'Today is '+T0.firstName+' '+T0.lastName+'''s birthday! Help him have a great day.'
WHEN 'F' THEN 'Today is '+T0.firstName+' '+T0.lastName+'''s birthday! Help her have a great day.'
ELSE 'Today is '+T0.firstName+' '+T0.lastName+'''s birthday!'
END
ELSE
CASE T0.sex
WHEN 'M' THEN 'Today is '+T0.firstName+' '+T0.lastName+' from '+T1.Name+'''s birthday! Help him have a great day.'
WHEN 'F' THEN 'Today is '+T0.firstName+' '+T0.lastName+' from '+T1.Name+'''s birthday! Help her have a great day.'
ELSE 'Today is '+T0.firstName+' '+T0.lastName+' from '+T1.Name+'''s birthday!'
END
END AS 'BirthdayText'
FROM OHEM T0
LEFT JOIN OCRY T1 ON T0.workCountr = T1.Code
WHERE T0.empID = DocKey@
)<img src="https://www.boyum-it.com/PostBirthdayWishesToMicrosoftTeams/Cupcakes.png"/>
- You can tweak the SQL as you please and use another image if you please
- Go to Administration > Add-ons > B1 Usability Package > Module Configuration > B1 Print and Delivery > Report Configuration
-
- Give the configuration a description
- Choose Category "Custom"
- Choose Birthday Bot as type (aka the Mass Deliver Configuration you created in step 1)
- Choose the Dummy Crystal Report you created in step 2 as Crystal Report
- Choose the Report Action you created in step 3 as Report Action for "Email"
-
- It is now possible to test the feature using Mass Delivery (Given that you set up an employee to have their birthday on the day you set it up)
- Go to Administration > Add-ons > B1 Usability Package > Module Configuration > B1 Print and Delivery > Schedules
- Set the feature to run on a schedule (in my case I've set it up to send out via the Server component every day at 8 o clock)
Comments
0 comments
Please sign in to leave a comment.