~4 min16 / 16

Best Practices

Guidelines for building workflows that are reliable, easy to maintain, and performant — from naming conventions to error-handling patterns used in production automations.

Project & Workflow Organisation

  • One workflow per logical task (e.g., ExtractInvoiceData, SendApprovalEmail)
  • Group related workflows in a single project folder
  • Use Invoke Workflow to compose small, reusable workflows rather than building one giant sequence
  • Keep workflow files under version control (e.g., Git) alongside your other code

Naming Conventions

ItemConventionExample
Workflow filesPascalCase verb-nounProcessInvoice.gbw
VariablescamelCase, descriptivecustomerName, totalAmount
Output variablesPrefix out_out_extractedText
Loop countersPrefix i_i_row, i_page
Flag booleansPrefix is or hasisLoggedIn, hasErrors
Activity display namesShort, action-oriented phraseClick Submit Button

Variables & Expressions

  • Declare all variables at the top of the workflow — not inline inside loops
  • Use strongly-typed variables (String, Int32, Boolean) rather than Object where possible
  • Avoid magic strings — assign repeated literals to a variable at the top (e.g., baseUrl = "https://app.example.com")
  • Use expressions ({{variableName}}) instead of hardcoding values in properties

Error Handling

  • Wrap every UI interaction (Click, TypeInto, GetText) in a Try/Catch block
  • Log the exception inside Catch: Log: "Error at step X — " + lastException.Message
  • Use Retry (3 attempts, 500 ms delay) for flaky selectors before marking as failed
  • Set Continue on Error = True only for truly optional steps — never for critical path actions
  • Always close the browser / application in a Finally block to avoid orphaned processes

Selector Stability

  • Prefer automationid or name over positional attributes like idx
  • Use wildcards (~ contains, ^ starts-with) for dynamic text that changes between runs
  • Validate selectors with the Selector Editor → Validate button before saving
  • Avoid recording selectors from loading / transitional screens — wait for the page to fully load first

Performance

  • Minimise Delay activities — replace fixed delays with WaitForElement or WaitForText
  • Open Excel once per workflow using ExcelApplicationContainer — do not open/close inside loops
  • Use DataTable + ForEachRow for batch operations instead of row-by-row API calls
  • Prefer HttpRequest over browser automation for APIs — it is 10–100× faster
  • Run independent branches in Parallel to reduce total execution time

Logging & Observability

  • Add a Log at the start and end of each major section: "Starting invoice extraction" / "Invoice extraction complete — 42 rows processed"
  • Log input variable values at the top so runs are reproducible from the Output Panel alone
  • Use Log(level: Warning) for recoverable issues, Log(level: Error) before rethrowing exceptions
  • When connected to Orchestrator, all log messages are captured in the Job history — keep them concise and searchable
Code Review ChecklistBefore marking a workflow as production-ready: ✅ all selectors validated, ✅ error handling on all UI steps, ✅ no hardcoded credentials, ✅ tested on a clean machine, ✅ uploaded to Orchestrator registry with a version label.
Was this helpful?