Skip to content

Conversation

@Charanjet
Copy link
Contributor

@Charanjet Charanjet commented Oct 16, 2025

PR Description:

Adds a dynamic user location validation script, comparing browser geolocation against the user’s assigned location in ServiceNow. Includes both a server-side Script Include and client-side Validator to block form submission if the user is outside the approved area. Folder references for both components are provided in the README.

Pull Request Checklist

Overview

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

Code Quality

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

Repository Structure Compliance

  • [x ] 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/
  • [x ] I've used appropriate sub-categories within the top-level categories
  • [x ] Each code snippet has its own folder with a descriptive name

Documentation

  • [x ] I've included a README.md file for each code snippet
  • [x ] 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

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

This document explains the User Location Validator solution, detailing how it restricts form submissions based on user location.
This document explains the User Location Validator solution, which restricts ServiceNow form submissions based on user location. It details the functionality of the Script Include and Client Script involved in the validation process.
Updated the README to clarify the User Location Validator functionality, including details on how it works, sample output, and usage notes.
Updated the readme to clarify the functionality and usage of the User Location Validator script, including details on how it works and sample output.
@kmohit2809 kmohit2809 requested a review from earlduque October 17, 2025 00:48
@kmohit2809 kmohit2809 self-assigned this Oct 17, 2025
@kmohit2809
Copy link
Contributor

@Charanjet please provide a valid title and description for your PR.

@Charanjet Charanjet changed the title Charanjeet hacktoberfest#2 Dynamic Location Validation Approach Oct 17, 2025
@Charanjet
Copy link
Contributor Author

@Charanjet please provide a valid title and description for your PR.

Hello @kmohit2809 ,
Sure, I have updated the PR description and title

@kmohit2809
Copy link
Contributor

@Charanjet please provide a valid title and description for your PR.

Hello @kmohit2809 ,

Sure, I have updated the PR description and title

Thanks @Charanjet , could you please make the readme more descriptive. Could you pkease shed some light on why the formula has been used this way to calculate the geo location and why is earth's circumference important in this? This will help others to understand your code better and utilise it when necessary. Thanks for your contribution. Once you make those changes then I should be able to merge this PR.

Copy link
Contributor

@SapphicFire SapphicFire left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you for your contribution

Comment on lines +22 to +27
var a = Math.sin(deltaLatitude / 2) * Math.sin(deltaLatitude / 2) +
Math.cos(allowedLatitude * Math.PI / 180) *
Math.cos(currentLatitude * Math.PI / 180) *
Math.sin(deltaLongitude / 2) * Math.sin(deltaLongitude / 2);

var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
Copy link
Contributor

Choose a reason for hiding this comment

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

Haversine! Love to see this

@SapphicFire SapphicFire removed the request for review from earlduque October 17, 2025 21:47
@SapphicFire SapphicFire self-assigned this Oct 17, 2025
@SapphicFire
Copy link
Contributor

Thanks @Charanjet , could you please make the readme more descriptive. Could you pkease shed some light on why the formula has been used this way to calculate the geo location and why is earth's circumference important in this? This will help others to understand your code better and utilise it when necessary. Thanks for your contribution. Once you make those changes then I should be able to merge this PR.

The description is solid for this contribution :)

@SapphicFire SapphicFire merged commit 639e1ba into ServiceNowDevProgram:main Oct 17, 2025
2 checks passed
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