RPA Reusable Workflows and Libraries
Imagine you build ten different bots and each one includes a "Login to SAP" sequence. When the SAP password policy changes or the login screen is updated, you must fix all ten bots individually. That is ten times the work, ten times the testing, and ten times the chance of missing one. Reusable workflows solve this problem entirely.
What Is a Reusable Workflow?
A reusable workflow is a standalone workflow file (.xaml) that performs one specific function. Instead of repeating those steps in every bot that needs them, you call the reusable workflow like a service — pass it the inputs it needs and receive the outputs it produces. Update the workflow once, and every bot that uses it gets the fix automatically.
Reusable Workflow Design Principle
WITHOUT REUSE (fragile): ───────────────────────────────────────── Bot A: [Login SAP] [Post Invoice] [Logout SAP] Bot B: [Login SAP] [Read Report] [Logout SAP] Bot C: [Login SAP] [Update Record] [Logout SAP] SAP login screen changes → Fix in Bot A, B, AND C. ───────────────────────────────────────── WITH REUSE (smart): ───────────────────────────────────────── SAP_Login.xaml ← single shared workflow SAP_Logout.xaml ← single shared workflow Bot A: Call[SAP_Login] → [Post Invoice] → Call[SAP_Logout] Bot B: Call[SAP_Login] → [Read Report] → Call[SAP_Logout] Bot C: Call[SAP_Login] → [Update Record] → Call[SAP_Logout] SAP login screen changes → Fix only SAP_Login.xaml once.
How to Create a Reusable Workflow
Step 1: Identify What to Extract
Look for steps that appear in more than one bot, or that are complex enough to deserve their own self-contained module. Good candidates include:
- Application login and logout sequences
- Data validation routines
- PDF extraction logic
- Email sending templates
- Error logging routines
- Queue item retrieval and status updates
Step 2: Define Inputs and Outputs (Arguments)
A reusable workflow communicates with the calling workflow through Arguments — variables that are passed in (In), returned out (Out), or both (In/Out).
Workflow: PostInvoiceToSAP.xaml IN Arguments: in_VendorName (String) in_InvoiceNo (String) in_Amount (Double) in_InvoiceDate (DateTime) OUT Arguments: out_SAPDocNumber (String) out_PostStatus (String) → "Success" or "Failed" out_ErrorMessage (String) → populated only if Failed
Step 3: Build the Workflow
Build the workflow using the defined arguments — not hardcoded values. The workflow should work correctly regardless of which bot calls it or what values it receives.
Step 4: Invoke from the Main Bot
Use the Invoke Workflow File activity in UiPath to call the reusable workflow. Map the main workflow's variables to the invoked workflow's arguments.
Invoke Workflow: "PostInvoiceToSAP.xaml" Arguments mapping: in_VendorName ← vendorName (from main workflow variable) in_InvoiceNo ← invoiceNo (from main workflow variable) in_Amount ← invoiceAmount in_InvoiceDate ← invoiceDate out_SAPDocNumber → sapDocNo (result stored in main variable) out_PostStatus → postResult
Libraries in UiPath
A Library is a packaged collection of reusable workflows and custom activities that can be published to the UiPath Orchestrator and installed in any project like a plugin. Libraries are the enterprise-grade version of reusable workflows — shareable across teams and projects, versioned, and centrally maintained.
Library vs Reusable Workflow
| Feature | Reusable Workflow (.xaml) | Library (.nupkg) |
|---|---|---|
| Scope | Within one project | Across all projects in the org |
| Distribution | Copy file to project folder | Publish to Orchestrator feed |
| Versioning | Manual | Automatic (NuGet versioning) |
| Appears in Activities Panel? | No — called via Invoke | Yes — appears as a custom activity |
| Best For | Within a single bot project | Organisation-wide shared capabilities |
Building an RPA Library: Common Components to Package
Authentication Library
- Login to SAP (input: credentials, output: session status)
- Login to Outlook (using Windows auth)
- Login to web portal (input: URL, username, password)
- Logout from any application
Data Utilities Library
- Read Excel range to DataTable
- Write DataTable to Excel
- Filter DataTable by column value
- Convert currency string to Double
- Format date to string in specified format
Notification Library
- Send standard alert email (input: recipient, subject, body, attachments)
- Send exception email with screenshot
- Send daily summary report
Framework: The Robotic Enterprise Framework (REFramework)
UiPath provides a pre-built framework called REFramework — a template project built entirely on reusable workflows and best practices for:
- Initialisation (loading config, opening apps)
- Queue-based processing (get item, process, mark result)
- Error handling at every level
- Clean shutdown (closing apps, sending summaries)
Using REFramework means you do not have to build error handling and queue management from scratch. Most enterprise bots are built on REFramework, so understanding it is a key career skill.
REFramework State Machine
┌───────────────────────────────────────────────┐ │ REFramework States │ │ │ │ [Init] ──────────────────────▶ [Get TX Data] │ │ │ │ │ │ │(init failed) (item found) │ │ ▼ ▼ │ │ [End] [Process Transaction] │ │ ▲ │ │ │ │ (success/failure) │ │ │ │ │ │ └────────────────────────┘ │ │ (no more items → End) │ └───────────────────────────────────────────────┘
Naming Conventions for Reusable Workflows
- Use a verb-noun pattern: GetCustomerData.xaml, PostInvoice.xaml, SendAlertEmail.xaml
- Prefix with application name when specific to one system: SAP_Login.xaml, CRM_CreateRecord.xaml
- Prefix arguments clearly: in_ for inputs, out_ for outputs, io_ for in-out
- Keep each workflow focused on one task — avoid "do everything" workflows
Summary
Reusable workflows eliminate duplication by extracting common functionality into standalone files that any bot can call. Arguments pass data in and out. Libraries package workflows for organisation-wide sharing and versioning through Orchestrator. REFramework provides a production-ready skeleton built on reusable workflows, queue management, and layered error handling. Building with reusability in mind from the start reduces development time, maintenance effort, and the risk of inconsistent behaviour across your bot portfolio.
