Has Suffix
Checks if a string ends with a specified suffix, returning true or false.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- String - The string to check.
- Suffix - The suffix to look for at the end of the string.
Options
This node does not have configurable options.
Output
- Result - Boolean value:
trueif string ends with suffix,falseotherwise.
How It Works
The Has Suffix node checks if a string ends with the specified suffix:
- Case-sensitive: ".PDF" and ".pdf" are different
- Exact match: Suffix must match exactly at the end
- Returns boolean: true if ends with suffix, false otherwise
- Empty suffix: Always returns true
Usage Examples
Example 1: Check File Extension
- String:
"document.pdf" - Suffix:
".pdf" - Result:
true
Example 2: Validate Email Domain
- String:
"user@example.com" - Suffix:
".com" - Result:
true
Example 3: Check URL Path
- String:
"https://api.example.com/v1/users" - Suffix:
"/users" - Result:
true
Example 4: Case Sensitivity
- String:
"image.PNG" - Suffix:
".png" - Result:
false(different case)
Example 5: Suffix Not Matching
- String:
"document.pdf" - Suffix:
".xlsx" - Result:
false
Tips
- Perfect for file extension validation
- Use for domain validation (email, URLs)
- Great for endpoint checking in APIs
- Search is case-sensitive - use Lowercase node first for case-insensitive check
- More specific than Includes - only checks the end
- Use with If node for conditional file processing
Common Errors and Solutions
Error: Returns false when suffix should match
- Cause: Case sensitivity mismatch (.jpg vs .JPG)
- Solution: Convert both to same case before checking:
1. Lowercase both string and suffix
2. Then use HasSuffix
Error: Extra spaces causing mismatch
- Cause: Trailing whitespace in string
- Solution: Use Trim node first to remove trailing whitespace
Practical RPA Examples
Example: Filter PDF Files
String: ${msg.filename}
Suffix: ".pdf"
Result: true/false
Action: Process only PDF files
Example: Validate Image Files
String: ${msg.file}
Suffixes to check: ".jpg", ".png", ".gif"
Action: Accept only image files
Example: Check Corporate Email
String: ${msg.email}
Suffix: "@company.com"
Result: true
Action: Verify employee email
Example: Detect API Version
String: ${msg.endpoint}
Suffix: "/v2"
Result: true
Action: Use v2 API handlers
Example: Validate Compressed Files
String: ${msg.filename}
Suffix: ".zip"
Result: true
Action: Extract archive
Example: Check Script Files
String: ${msg.file}
Suffix: ".js"
Result: true
Action: Execute JavaScript file
Pattern: Multiple File Type Validation
Check for multiple acceptable extensions:
Check 1: HasSuffix ".xlsx"
Check 2: HasSuffix ".xls"
Check 3: HasSuffix ".csv"
Result: Accept if any check returns true
Pattern: File Type Routing
Route files based on extension:
If HasSuffix ".pdf" → PDF processing
If HasSuffix ".xlsx" → Excel processing
If HasSuffix ".csv" → CSV processing
Else → Unsupported file type error
Case-Insensitive Suffix Check
For case-insensitive matching (important for file extensions):
Step 1: Lowercase on input string
Step 2: Lowercase on suffix
Step 3: HasSuffix check
Result: Case-insensitive suffix match
Example:
"IMAGE.PNG" → "image.png"
".png" → ".png"
Result: true
Common File Extension Checks
Document Files
.pdf,.doc,.docx,.txt
Spreadsheets
.xlsx,.xls,.csv
Images
.jpg,.jpeg,.png,.gif,.bmp
Archives
.zip,.rar,.tar,.gz
Code Files
.js,.py,.java,.go
Combining with HasPrefix
Validate both start and end:
Example: Validate file path and extension
1. HasPrefix "/uploads/" → Check directory
2. HasSuffix ".pdf" → Check file type
Both must be true for valid file