Skip to content

Conversation

@SumithThota
Copy link
Contributor

PR Description:

Prevent Invalid User ID

This ServiceNow Business Rule prevents inserting or updating a record when:

  • user_name is missing or invalid.
  • Both first_name and last_name are missing or invalid.

Functionality Breakdown

1. isInvalid(value)

  • Detects invalid values in user fields.
  • Returns true if:
    • Value is null, undefined, or empty ("")
    • Value (after trimming spaces and lowering case) equals "null"

Example:

isInvalid(null);        // true
isInvalid("");          // true
isInvalid("NULL");      // true
isInvalid("john");      // false

2. current.setAbortAction(true)

  • Stops the record from being inserted or updated.
  • Used inside Before Business Rules.
  • Prevents saving invalid data to the database.

3. gs.addErrorMessage("...")

  • Displays a user-friendly error message at the top of the form.
  • Helps users understand why the save was blocked.

Notes

  • Case-insensitive — handles "null", "NULL", "Null", etc.
  • Works best in Before Business Rules to stop invalid data before saving.
  • Adding gs.addErrorMessage() helps users understand the validation reason.

Pull Request Checklist

Overview

  • Put an x inside of the square brackets to check each item.
  • I have read and understood the CONTRIBUTING.md guidelines
  • My pull request has a descriptive title that accurately reflects the changes and the description has been filled in above.
  • I've included only files relevant to the changes described in the PR title and description
  • I've created a new branch in my forked repository for this contribution

Code Quality

  • My code is relevant to ServiceNow developers
  • My code snippets expand meaningfully on official ServiceNow documentation (if applicable)
  • I've disclosed use of ES2021 features (if applicable)
  • I've tested my code snippets in a ServiceNow environment (where possible)

Repository Structure Compliance

  • I've placed my code snippet(s) in one of the required top-level categories:
    • Core ServiceNow APIs/
    • Server-Side Components/
    • Client-Side Components/
    • Modern Development/
    • Integration/
    • Specialized Areas/
  • I've used appropriate sub-categories within the top-level categories
  • Each code snippet has its own folder with a descriptive name

Documentation

  • I've included a README.md file for each code snippet
  • The README.md includes:
    • Description of the code snippet functionality
    • Usage instructions or examples
    • Any prerequisites or dependencies
    • (Optional) Screenshots or diagrams if helpful

Restrictions

  • My PR does not include XML exports of ServiceNow records
  • My PR does not contain sensitive information (passwords, API keys, tokens)
  • My PR does not include changes that fall outside the described scope

@ravichandra1998g ravichandra1998g self-assigned this Oct 21, 2025
Copy link
Contributor

@ravichandra1998g ravichandra1998g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @SumithThota
Thank you for your submission. It appears that this pull request contains more files than described in the title. (it contains 4 files).
Please review and update the pull request to either remove the extra/unintended files or to update the description to be more comprehensive. Ensure your contributions are meaningful and adhere to the project’s standards. [If applicable: You can create a new branch on your forked repository to avoid accidental inclusions of new commits in the future.]. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.

@SumithThota
Copy link
Contributor Author

SumithThota commented Oct 21, 2025

Hi @ravichandra1998g Actully there exists 2 readme files in each locations 1 and 2 that is the reason they are conflicting each other and got ignored 1 file while pushing. Do I need to raise an Issue for this and maintain the correct README.md file at these locations, please do respond

@SumithThota
Copy link
Contributor Author

@ravichandra1998g I just raised a new issue #2367 regarding this problem could you check it out and assign that issue to me

@wiz0floyd
Copy link
Contributor

Just update your PR description to make it clear that those readme changes are intended to be part of this pr and it'll be good to go.

@SumithThota
Copy link
Contributor Author

@wiz0floyd yeah the #2381 has just merged if this PR #2357 merges does it conflicts each other regarding the issue of readme files or should i need to create new PR for the current changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants