Hi everyone,
I’m building an “Off” button for managers: they pick a replacement and absence start/end dates, and the replacement should be set as their Delegated Approver (User.DelegatedApproverId) on the start date and removed on the end date.
Setup
- Custom object Absence_Delegation__c (Delegate, Start Date, End Date), created by a Screen Flow.
- A daily schedule-triggered Flow on that object: if Start Date = today, set DelegatedApproverId on the record’s creator; if End Date = today, clear it.
Problem
Debug works, but the scheduled run in the sandbox and the selected delegate user isn't added as a delegate approver on the running flow's user page.
I also can’t use $Flow.CurrentDate in the Start element’s entry conditions to limit the flow to records starting or ending today.
What could I be missing to fix this?
Thanks! Happy to share screenshots.
#Salesforce Admin #Salesforce #Flow
@Nizar Am From the canvas, the likely culprit is the Get Delegations element. I can't see what's inside each element, so the rest is inference until I see them.
1. Get Delegations looks redundant and probably breaks things
A schedule-triggered flow already runs once per record of Absence Delegation, and each run has that record as {!$Record}. A Get Records element right after the Start element means one of two things:
- It returns one record (the first match). Then the Decision and updates run against that record, not the one the interview is processing, so most records are skipped or the wrong one is used.
- It returns a collection. Then the Decision can't compare a date on it, and anything using it is unreliable.
Debug is more forgiving because you pick a single record, so it can look fine there and fail on the scheduled run.
Fix: delete Get Delegations. In Delegation Status, use {!$Record.Start_Date__c} = {!$Flow.CurrentDate} for "Start Date is Today" and {!$Record.End_Date__c} = {!$Flow.CurrentDate} for "End Date is Today". $Flow.CurrentDate works inside a Decision, just not in the Start element's entry conditions.
2. Check that the updates target the manager, not the running userBoth Update Records elements should be on
User, with a filter of Id = {!$Record.CreatedById} (or a dedicated Manager lookup, which is safer).
- Add Delegate: set DelegatedApproverId = {!$Record.Delegate__c}.
- Remove Delegate: set DelegatedApproverId to null. Use "Set field values" and leave the value blank, or use a null/empty text variable.
- Don't use "Use the IDs stored in a record variable" on a User from a Get. If the User comes from $User, the scheduled run lands on the Automated Process user, which matches what you saw.
3. Things on the canvas worth checking- Start time: it's set to 11:15 today, which has already passed in your time zone (it's about 17:00 for you). Confirm in Setup → Scheduled Jobs that the job exists and shows a next run for tomorrow. Also check the flow is Active, since a saved but inactive flow won't run.
- Failures: Setup → Paused and Failed Flow Interviews and the flow error emails will show what the last scheduled run did.
- No fault paths: the two updates have none. Add them, since a failed User update would otherwise be silent.
- Entry conditions: the Start element has none, so every Absence Delegation record is processed daily. That's fine at low volume. If it grows, add formula fields (Starts_Today__c, Ends_Today__c) and filter on them in the Start element.