A Custom action for Generating Random Passwords , Tokens and PIN #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Custom Flow Action: Random Password,Token and PIN Generator
What does this action do?
Creates random strings for passwords, tokens, test data, or unique identifiers with customizable character sets using JavaScript's Math.random().
Problem Solved
Use Cases
ServiceNow can automatically generate initial or temporary user passwords when a new account is created. For instance, a Flow can generate a secure password and notify the user by email during user onboarding to ensure secure first-time login.
Secure tokens or API keys are generated for integrations, application authorization, or OAuth flows. ServiceNow internally generates tokens for OAuth clients and can be extended to generate custom tokens for external integrations requiring timely, unique, and non-guessable API keys.
Development and testing processes often require large volumes of randomized test data. Using scripted generators, unique random strings are created for testing user accounts, transaction IDs, or sample inputs to ensure robust validation of workflows in ServiceNow sandbox environments.
Workflows and business rules frequently generate unique IDs for records, such as incident numbers, request tokens, or session IDs. For example, a catalog item request might receive a unique alphanumeric identifier created programmatically to track and audit the request's lifecycle securely.
Though ServiceNow manages encrypted keys internally, workflows can create random encryption keys or salts used in custom encryptions or integrations. This is critical for securing communication with external systems or storing sensitive information in the platform securely.
Inputs (7 parameters)
lengthinclude_uppercaseinclude_lowercaseinclude_numbersinclude_special_charsspecial_chars_listexclude_ambiguousOutputs (3 parameters)
random_stringentropy_bitscharacter_types_usedKey Features
Testing Performed
Example Usage in Flow
Scenario 1: Generate Temp Password
Scenario 2: Generate Numeric PIN
Scenario 3: Generate API Token
Security Considerations
Code Quality
Quality Checklist:
This action fills a common need in ServiceNow automation and provides a secure, flexible solution for random string generation.
Visual Proof
Test Case Scenario