Schedule process until file becomes available

I’m trying to set up a process in Orchestrator that runs monthly, but only starting from the 6th of each month, when a file is expected to be available.

Here’s what I need the process to do:

  • It should not run before the 6th of the month.
  • When it runs, it should check for the presence of a specific file.
  • If the file is not available, the job should throw an error and be marked as failed.
  • Once the process successfully runs, it should not run again until the next month.
  • If the file isn’t available on the 6th, it should keep checking daily until it is.

Has anyone implemented something similar?
Any advice, best practices, or examples would be greatly appreciated!

@danielf

Schedule the bot to run on 6th by default..if it is successful then good..if not include code to create one more schedule to run on 7..or use a queue approach and create a queue item with 1 day deferred date so that it runs the next day and this continues till the file is found

if queue model is followed then on first trigger add a new queue item so that the process starts to check

cheers

1. Orchestrator Trigger Setup

  • Use CRON Expression:

    0 8 6-31 * * 
    
    • Runs daily at 08:00 AM from the 6th to the 31st of each month.
    • Ensures the process does not run before the 6th.

2. Orchestrator Asset for State Management

  • Asset Name: LastSuccessfulRunMonth
  • Type: Boolean
  • Initial Value: False
  • Purpose: Tracks if the file has already been processed for the current month.

3. Workflow Logic (Best-Practice Approach)

Implement using REFramework or similar layered architecture.

Initialization State:
  • Read asset LastSuccessfulRunMonth
Conditions:
  1. If DateTime.Now.ToString("dd") < 6 → Log info and exit.
  2. If LastSuccessfulRunMonth is True → Log info: “Already processed this month” → exit.
  3. Check File Exists:
  • If exists:
    • Proceed to process.
    • On success, update `LastSuccessfulRunMonth = True.
  • If not exists:
    • Throw BusinessRuleException("Expected file not found") → this will fail the job and retry tomorrow via trigger.

4. Exception Handling

  • Use Business Rule Exceptions to clearly separate “expected failures” (like missing file) from system errors.
  • Let failed jobs retry naturally through the next day’s trigger.

5. Logging & Monitoring

  • Use structured logs:
    • Log Message: "Waiting for 6th of the month, exiting early."
    • Log Message: "Already processed for this month, exiting."
    • Log Message: "File found. Proceeding with processing."
  • Optionally: add alerts (email/Teams) if file not found after X days.

Thanks for the input. Just to clarify your suggestion on programmatically creating a new schedule:

As far as I’m aware, Orchestrator don’t allow creating or modifying schedules dynamically via the process itself. Could you elaborate on how you envision this being implemented?

Yeah, UiPath Orchestrator can’t create or modify schedules dynamically from within running processes. It’s usually done manually via the Orchestrator UI or via external API calls with the right permissions.

Set up fixed schedules in Orchestrator (e.g., a daily or CRON trigger) and handle all dynamic execution logic in your workflow - using assets, queues, or flags to control when the process runs or exits.

Dynamic schedule creation would require an external script or automation using Orchestrator’s API (if supported), which involves admin-level permissions and additional complexity. But for most cases, controlling the logic inside the workflow combined with fixed triggers is the best and most maintainable practice.

@danielf

you can create schedule using the following apis

for api details check swagger <orchetsratorurl>/swagger/index.html

also as mentioned second option is leverage a queue item and add two triggers one queue trigger and second trigger on 6th of every month

Hope this helps

cheers

1 Like

Time trigger for the 6th, and then a queue trigger so that the process can create a queue item if the file doesn’t exist (with a postponement on the queue item for when you want it to run next) is a great solution. Just make sure the process is set up to get the queue item and mark it complete.

I would suggest you to split your process into 2 parts

Part 1: Dispatcher - This will add one item into your queue. Queue details should contain the expected file path only. This should be scheduled for every 6th day of the month using Cron expression
example:0 8 6-31 * *

Part 2: Performer - Processing the item. This - You can schedule for every day. If item is not available - BOT will check for item and completes the run without processing. On 6th day - BOT will check and identify that a queue item is available to process. Based on the file path mentioned in the queue item, BOT will check for that file. if the file is not available - send exception email as part of the process only and postpone the queue item for next day. This will continue till the file is available.