To String
Converts a boolean value to its string representation ("true" or "false"), making it suitable for logging, display, reporting, or string-based operations in RPA flows.
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.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Bool Value - The boolean value to convert to a string. This can be:
- A direct boolean value (true/false)
- A variable containing a boolean value
- A JavaScript expression that evaluates to a boolean
- An AI-generated boolean value
- The result from a previous boolean operation or assignment
Output
- String - The string representation of the boolean value, stored in the Message scope with the name
str. The output will be exactly "true" or "false" (lowercase).
How It Works
When executed, the ToString node:
- Retrieves the boolean value from the input
- Converts it to its string representation using Go's standard boolean formatting
- Stores the result as a string in the output variable
Conversion Table:
| Input Boolean | Output String |
|---|---|
true | "true" |
false | "false" |
Use Cases
1. Logging and Debugging
Convert boolean flags to strings for inclusion in log messages:
// After ToString node
log.info("Validation result: " + msg.str);
// Output: "Validation result: true"
2. Report Generation
Include boolean status in reports or notifications:
// After ToString node
msg.reportLine = "Processing completed: " + msg.str;
// Result: "Processing completed: false"
3. Email Notifications
Format boolean values for human-readable email content:
// After ToString node
msg.emailBody = "Account active: " + msg.str;
// Sends: "Account active: true"
4. String Concatenation
Combine boolean values with other strings:
// After ToString node
msg.status = "Feature enabled: " + msg.str + ", version: 2.0";
// Result: "Feature enabled: true, version: 2.0"
5. CSV/Excel Export
Prepare boolean data for export to CSV or Excel files:
// After ToString node
msg.csvRow = msg.name + "," + msg.str + "," + msg.date;
// Result: "John Doe,true,2024-01-15"
6. API Requests
Convert boolean values to strings for APIs that expect string parameters:
// After ToString node
msg.queryParams = "?active=" + msg.str + "&verified=true";
// Result: "?active=false&verified=true"
Examples
Example 1: Simple Conversion
Convert a validation result to string:
Configuration:
- Bool Value:
true - Output:
msg.str = "true"
Example 2: Logging Validation Status
Convert a validation result and use it in a log message:
Configuration:
- Bool Value:
${msg.validationPassed} - Output:
msg.str(contains "true" or "false") - Usage: Send to Log node with message:
Validation status: ${msg.str}
Example 3: Building Report Data
Prepare boolean flags for a status report:
Flow:
- Check system status (result:
true) - ToString node converts to
"true" - Concatenate:
"System operational: " + msg.str - Result:
"System operational: true"
Example 4: CSV Row Creation
Create a CSV row with boolean data:
Configuration:
- Bool Value:
${msg.isProcessed} - Output:
msg.str - Next Node: String Concat node
${msg.recordId},${msg.recordName},${msg.str},${msg.timestamp} - Result:
"12345,Sample Record,true,2024-01-15 10:30:00"
Example 5: Conditional Message Formatting
Format different messages based on boolean state:
Flow:
- Operation node checks permissions (result in
msg.hasAccess) - ToString converts
msg.hasAccessto string - If node checks the original boolean
- Build message using string:
"Access granted: " + msg.str
Example 6: API Integration
Prepare boolean parameters for an API call:
Configuration:
- Bool Value:
${msg.autoRenew} - Output:
msg.str - Usage in HTTP Request:
URL: https://api.example.com/subscription?auto_renew=${msg.str}
Result: https://api.example.com/subscription?auto_renew=true
Tips for Effective Use
-
Use for Human-Readable Output
- Convert boolean values before displaying them to users
- Include in email notifications, reports, and UI messages
-
Consistent Formatting
- The output is always lowercase ("true" or "false")
- If you need different formatting (TRUE, Yes/No, 1/0), use additional string manipulation
-
Combine with String Operations
- Use string concatenation nodes to build complete messages
- Leverage template literals for more complex string building
-
Performance Consideration
- This is a lightweight operation with minimal performance impact
- Safe to use in high-frequency loops
-
Naming Convention
- Change the output variable name to be more descriptive
- Example:
statusText,resultString,flagDescription
Common Errors and Solutions
Error: "Bool Value is undefined"
Cause: The input boolean value hasn't been set or the variable doesn't exist.
Solution:
- Ensure a previous node sets the boolean value
- Check variable names and scopes
- Verify the boolean value is available in the message context
Error: "Type mismatch"
Cause: The input value is not a boolean type.
Solution:
- Convert to boolean first: Use a JavaScript expression like
${!!msg.value} - Use comparison to get boolean:
${msg.count > 0} - Verify the source node outputs a boolean
Unexpected Output Format
Issue: Need "Yes/No" or "1/0" instead of "true/false".
Solution:
- After ToString, use a String Replace or If node to convert:
// Using If node:
if (msg.boolValue) {
msg.customStr = "Yes";
} else {
msg.customStr = "No";
}
Case Sensitivity Issues
Issue: Need uppercase "TRUE" or "FALSE".
Solution:
- Use a String operation after ToString to convert to uppercase:
msg.upperStr = msg.str.toUpperCase();
// Result: "TRUE" or "FALSE"
Alternative Formatting Options
While ToString always outputs lowercase "true" or "false", you can easily transform the output:
Convert to Yes/No
// After ToString node, in a JavaScript node:
msg.yesNo = (msg.str === "true") ? "Yes" : "No";
Convert to 1/0
// After ToString node, in a JavaScript node:
msg.numeric = (msg.str === "true") ? "1" : "0";
Convert to Custom Labels
// After ToString node, in a JavaScript node:
msg.status = (msg.str === "true") ? "Enabled" : "Disabled";
// or
msg.status = (msg.str === "true") ? "Active" : "Inactive";
// or
msg.status = (msg.str === "true") ? "Success" : "Failed";
Uppercase Output
// After ToString node, in a JavaScript node:
msg.upperStr = msg.str.toUpperCase();
// Result: "TRUE" or "FALSE"
Best Practices
- Use When Needed - Only convert to string when actually needed for string operations
- Name Descriptively - Use clear output variable names that indicate the content
- Consider Alternatives - For custom formatting, consider using If nodes or JavaScript directly
- Preserve Original - Keep the original boolean value if you need it for logic operations
- Document Purpose - Use the node name to indicate why you're converting to string
- Chain Operations - Combine with other string nodes for complex formatting needs
Performance Considerations
- ToString is a very fast operation with negligible performance impact
- Safe to use in high-frequency loops and batch processing
- No memory overhead - output strings are small fixed-size values
- Thread-safe and suitable for concurrent flows
Integration Examples
With Log Node
// After ToString
"Validation completed: " + msg.str
With Email Node
// Email body template
Dear User,
Your account status:
- Active: ${msg.activeStr}
- Verified: ${msg.verifiedStr}
- Subscribed: ${msg.subscribedStr}
With Database Insert
// Prepare data for database
{
user_id: msg.userId,
is_active: msg.str, // "true" or "false" as string
timestamp: msg.timestamp
}
With CSV Writer
// CSV header: Name,Email,Active,Verified
// CSV row:
${msg.name},${msg.email},${msg.activeStr},${msg.verifiedStr}
Related Nodes
- Assign - Assign boolean values that can then be converted to strings
- Operation - Perform logical operations before converting results to strings
- String Concat - Combine the string output with other strings
- Log - Use the string output in log messages
- HTTP Request - Include string-formatted boolean values in API calls
- Email - Include boolean status in email notifications
- CSV Writer - Export boolean data as strings to CSV files