Prerequisites:
- Windows server
- .NET 7 bundle with hosting bundle
- Run time
Register App in Azure:
- Create an App Registration in Azure and note down the Client ID and Tenant ID. (Azure Portal → Microsoft Entra ID → App registrations → Your application)
- Create a Client Secret under the App Registration and securely save the Secret Value. Make sure to copy the value immediately, as it will not be shown again.
- Grant access to the Dynamics 365 API by adding the required API permissions to the App Registration.
- Grant Admin Consent for the API permissions.
- Microsoft Entra ID → App registrations → Your App → API permissions → Add a permission
Dynamics client Id Registration:
- In Dynamics 365 Finance & Operations, go to System administration → Setup → Microsoft Entra applications and register the application’s Client ID.
- Assign the appropriate Dynamics security role(s) to the registered application/user so it has permission to access the required APIs and data.
- Use the Tenant ID, Client ID, Client Secret, and Dynamics 365 environment URL to request an access token and call the Dynamics API.
Configuration Setup:
- First Run Configuration Setup application as “run as administrator” from the downloaded folder (ConfigurationSetup) of installation from path (SetConfigurationForSyncAttendanceData.exe)
- An alert will be popup out:

- OK and you will see a complete form:

Note: If you are using OAuth 2.0 / V2 than you need to fill scope field:
- https://login.microsoftonline.com/f2d7d1d6-f46f-4639-ad01-176bd6aeef8e/oauth2/v2.0/token
- https://login.microsoftonline.com/yourtenantId/oauth2/v2.0/token
- if you are using oauth2/v2.0 you need to fill the scope filed as well
- e.g scope
- yourdynamicsUrl/.default
- Enter the server information and table name where the attendance data is stored. In the Column Mapping section, specify the corresponding column names from your table. Then, enter your Dynamics 365 information and configure the sync conditions based on the required criteria: Current Date, Date From, Date To, or Worker (Employee ID).
- Also set Schedule Hours field to recursively run the job of sync data based on your condition (date from, date to and worker) after your mentioned hours in the field of Schedule Hours field and then press the save button to save configurations. (all * fields must be filled)
Note: If you need to run the service at specific times you need to use the schedule times filed at the bottom in which you will select those times in which you want your service to run

- Once your information is saved, the next time you open the application by running it as Administrator, your saved data will be automatically loaded.
Create View in your Database
USE [your database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[vw_UserTransactionLog]
AS
SELECT
[USERID],
[CHECKTIME],
-- Keep 1 as 1; everything else becomes 0
CASE
WHEN [CHECKTYPE] = 1 THEN 1
ELSE 0
END AS [CHECKTYPE],
-- Time as seconds from midnight
-- Example: 12:59:00 = 46740
DATEDIFF(
SECOND,
CAST([CHECKTIME] AS DATE),
[CHECKTIME]
) AS [TimeInt],
-- Date only
CAST([CHECKTIME] AS DATE) AS [TransactionDateOnly]
FROM [CHECKINOUT]; // Your current Table from view will fetch data
GO
//If your table has I (In) and O (Out) values than use this view
USE [your database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER VIEW [dbo].[vw_UserTransactionLog]
AS
SELECT
C.[USERID],
U.[Badgenumber] AS [BadgeNumber],
C.[CHECKTIME],
-- I = 1 (In), 0 = 0 (Out), anything else = 0
CASE
WHEN UPPER(LTRIM(RTRIM(C.[CHECKTYPE]))) = 'I' THEN 1
ELSE 0
END AS [CHECKTYPE],
-- Time as seconds from midnight
-- Example: 16:00:13 = 57613
CAST(
DATEPART(HOUR, C.[CHECKTIME]) * 3600
+ DATEPART(MINUTE, C.[CHECKTIME]) * 60
+ DATEPART(SECOND, C.[CHECKTIME])
AS INT
) AS [Time],
Service Installation:
- Open command line as “Run as administrator”.
- Prepare command according to your file path
sc create SyncAttendanceService binPath= “
yourDrivePath\SyncAttendanceSetupsAndInstallationDocument\WindowServiceApi\SyncAttendanceData.exe”
- Execute above command to create service.
- Now for start this service needs to run command “sc start SyncAttendanceService”.
- For your information, if you want to stop service so please run command “sc stop SyncAttendanceService”.
- Once service is started you can see logs in your server c drive under path “C:\logs\SyncAttendanceService\” with current date folder.
Note:
- If you want to change schedule of service execution by updating ScheduleHours field from set configuration application (run as administrator), then you need to restart this above created service by executing command (“sc restart SyncAttendanceService”) in command line (command line open as run as administrator).
Delete the service:
sc delete "ServiceName"
New Build of Service:
- Open command line as “Run as administrator”.
- Run command to stop service “sc stop SyncAttendanceService”.
- Run command to start “sc start SyncAttendanceService”.
Creation of View
sync-attendance.zip
Checking Logs
Once you run the service you can see the logs in the C drive logs folder check for recent logs C:\logs

Note: If the service stops midway after making multiple calls, check the flag file. If its status is “In Progress,” update it to “Done” by changing the text from “In Progress” to “Done.”

