Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Integration/Scripted REST Api/Return User Info by Email/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 🌐 Scripted REST API – Get User Info by Email

## πŸ“‹ Description
This Scripted REST API returns basic user information (name, title, department, location) based on an email address passed as a query parameter.

## πŸ“¦ Files Included
- `ScriptedRESTAPI_GetUserInfo.js`

## πŸ’‘ Use Case
Useful for integrations or external systems needing user data from ServiceNow without exposing full records.

## πŸ›  Setup Instructions
1. Create a new **Scripted REST API** with namespace `x_userinfo`.
2. Add a resource with path `/get_user` and method `GET`.
3. Paste the provided script into the resource script field.
18 changes: 18 additions & 0 deletions Integration/Scripted REST Api/Return User Info by Email/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function process(request, response) {
var email = request.queryParams.email;
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', email);
userGR.query();

if (userGR.next()) {
return {
name: userGR.getValue('name'),
title: userGR.getValue('title'),
department: userGR.getDisplayValue('department'),
location: userGR.getDisplayValue('location')
};
} else {
response.setStatus(404);
return { error: 'User not found' };
}
})(request, response);
Loading