What is “Scheduling Flows from Portal Actions”?
In PowerApps Portals, users can interact with custom buttons or forms. You can use these interactions to trigger Power Automate flows, and further schedule those flows to run later instead of instantly. This is essential for:
- Delay-based approvals
- Notifications at specific times
- Automated jobs based on user requests
- System clean-ups or checks at off-hours
Step-by-Step Guide
Step 1: Set Up the PowerApps Portal
First, ensure you have:
- A PowerApps Portal app created.
- Web pages and forms (Entity/Basic Forms or Custom Web Pages).
- A portal page or custom button where user will trigger an action.
Step 2: Create a Power Automate Flow
Option A: Instant Cloud Flow (Manually Triggered)
- Go to Power Automate.
- Create a new Instant Flow.
- Choose the PowerApps trigger (for direct integration with portals).
Option B: Scheduled Cloud Flow
- Create a Scheduled Flow (e.g., run every day or once at a time).
- Add a condition to check a flag or datetime field before proceeding.
- You can build a logic where data inserted by the portal is later picked up by this scheduled flow.
Use Dataverse tables to store requests with
RunAt
datetime values.
Step 3: Accept Scheduled Time from Portal
- In your Portal Form or Custom Button, collect:
- Flow action (like “Send Reminder” or “Start Process”).
- Schedule datetime (e.g.,
RequestedRunTime
).
- Store this data in Dataverse.
You can create a custom Dataverse table like ScheduledJobs
:
Title
RequestedBy
RunAt
(Datetime)Status
(Pending, Running, Completed)TriggerType
(Manual, Automated)
Step 4: Trigger Flow from Portal Action
When a user clicks a button:
- Use JavaScript or Portal Custom Web Page logic to call a Power Automate flow.
- That flow should create a record in the
ScheduledJobs
table with relevant details and run-at time.
Use Power Automate with:
- Trigger: PowerApps or HTTP Request
- Action: Add a new record to Dataverse.
Step 5: Run Scheduled Flow to Pick Up Records
Create a Scheduled Power Automate flow:
- Trigger: Recurrence (every 5 or 15 minutes)
- Step 1: List rows from the
ScheduledJobs
table- Filter for
Status = 'Pending' AND RunAt <= UtcNow()
- Filter for
- Step 2: Loop through the jobs and:
- Perform the desired action (e.g., send email, update record)
- Update
Status
to “Completed” or “Failed”
Step 6: Monitor and Log Results
Use the Dataverse table to track:
- What was executed
- When it was executed
- What the output/result was
You can display this info on a portal page (e.g., “My Scheduled Jobs”).
Sample Use Case
Scenario:
On a portal page, users can request a “Reminder Email” to be sent to them at a specified time.
Flow:
- User picks a time and clicks “Schedule Reminder.”
- A Power Automate flow creates a row in
ScheduledJobs
withRunAt = selected time
. - Another recurring flow checks for due jobs and sends out emails.
Key Considerations
- Time Zone Handling: Always use
UTC
in flows and convert time on portal side if needed. - Security: Make sure only authenticated users can create scheduled actions.
- Capacity: Scheduled flows can only handle limited volume—consider batching for scale.
- Error Handling: Log and handle failed jobs with retry logic or notifications.
- Real-Time vs Scheduled: For immediate execution, use direct flow triggers. For future, rely on schedule logic.
Advanced Ideas
- Queue-Based Scheduling: Use Azure Service Bus or Power Automate Queues to control scheduled executions.
- Approval-Based Scheduling: Allow an admin to approve the scheduled flow before execution.
- CRON-like Expressions: Provide users with advanced scheduling options like weekly/daily.
Technologies Involved
- PowerApps Portals
- Microsoft Dataverse
- Power Automate Flows
- JavaScript (for portal actions)
- Custom Dataverse Tables (to store schedules)