Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# update a record in sys_user table

If we use the command below to update a record, it can lead to a problem.

grUser.get('grUser.get('62826bf03710200044e0bfc8bcbe5df9')');

If the record is not found in the table, the script will create a new one.

To make sure we are updating and not inserting, it is better to wrap up the get method with an If statement.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var grUser = new GlideRecord('sys_user');

if (grUser.get('62826bf03710200044e0bfc8bcbe5df9')) {
grUser.user_name = 'test.user';
grUser.first_name = 'test';
grUser.last_name = 'user';
grUser.email = 'test.user@servicenow';
grUser.update();
} else {
gs.info('Record not found.');
}