User report (Microsoft Graph)
Last updated
Was this helpful?
Last updated
Was this helpful?
This workflow retrieves a list of active users from Microsoft Graph on a scheduled basis, processes the data using Jinja list comprehension, and sends it to a specified email recipient. If the workflow fails at any step, a failure notification is sent to an admin.
This workflow uses:
A cron trigger to schedule execution.
Microsoft Graph integration to fetch user data.
Jinja for list comprehension to filter and format data.
Dynamic success and failure email notifications.
🐣 Stewart Says: Jinja makes it easy to process and filter data dynamically without needing external scripts. Perfect for lightweight automations like generating reports!
Navigate to Automations > Workflows in the left side menu.
Click Create to create a new Workflow.
Enter Microsoft Graph Special User Report Workflow
in the Name field.
Add any Tags you'd like, to stay organized.
Click Submit.
Click the Trigger button, denoted by a blue lightning bolt, in the top menu. Your load time to establish the trigger may take a moment.
Enter User Report Cron Trigger
in the Name field.
Toggle Enabled to on to activate this trigger.
With the trigger active, every form submission will start our new workflow.
Choose the Core - Cron Job
from the Trigger Type drop down menu field. You can type in this menu field to jump to your desired trigger type instead of scrolling through the long list.
Add the following under the Trigger Parameters menu:
Set a schedule for running the workflow in the Cron Schedule field, such as 09**1. This would run every Monday at 9:00 AM.
Click Submit at the bottom.
🐣 Stewart Says: No need to mess around with cron coding for your testing. Simply hit the test button at the top of your workflow to give it a spin!
Add the List Users action from Microsoft Graph to the workflow canvas.
Click on the On Success Transition.
Click the + button next to Data Aliases.
Type result
for the key.
Add the following to the value:
{{ RESULT.result.data.value }}
Click the + on the action.
Change the Condition of the transition to On Failure.
Click the + button next to Data Aliases.
Type failure_message
for the key.
Add the following to the value: Failed to list all users
🐣 Stewart Says: What the heck is {{ RESULT.result.data.value }}? Check out this video to learn more.
Change the name from core_noop
to filter_user_list
at the top right.
Click on the On Success Transition.
Click the + button next to Data Aliases.
Enter special_users
for the key.
Add the following to the value:
🐣 Stewart Says: Filtering the user data dynamically with Jinja ensures that you only process the relevant subset of users. This step prepares the data for the email. For our example, we only want to see users in the Main Office. So we use an “if statement” to only select “Main” Office workers, we'll then extract specific information about those users.
Connect the On Success transition of the List Users action to the filter_user_list Noop action.
Add the sendmail action from to the workflow canvas.
Change the name from core_sendmail
to send_success_email
at the top right.
Enter the following in the relevant fields of the configuration menu on the right:
Sender: Select an option.
Recipient: your-team@example.com , or whatever is your desired email address
Subject: Here’s your user list!
Message: Open the editor and paste in the code below, tailoring the message to your needs:
Connect the On Success transition from the Noop action to the Success sendmail action.
Add the sendmail action from to the workflow canvas.
Change the name from core_sendmail
to send_failure_email
at the top right.
Enter the following in the relevant fields of the configuration menu on the right:
Sender: Select an option.
Recipient: your-team@example.com , or your desired email addresses and however they are formatted
Subject: Workflow Failure: Special User Report
Message: Open the editor and paste in the code below, tailoring the message to your needs:
Temporarily edit the email action’s recipient to your email.
Click the test button at the top right of your workflow.
Click the Results icon, denoted by a graph, in the top menu. And, check your email inbox!
🐣 Stewart Says: Remember that you can filter for a different condition— like all users with the role Admin— to tailor the user report to your needs. Just update your Jinja code!
Add the noop action to the workflow canvas.