File tree 2 files changed +20
-0
lines changed
Background Scripts/Updating a record in the sys_user table
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ # update a record in sys_user table
2
+
3
+ If we use the command below to update a record, it can lead to a problem.
4
+
5
+ grUser.get('grUser.get('62826bf03710200044e0bfc8bcbe5df9')');
6
+
7
+ If the record is not found in the table, the script will create a new one.
8
+
9
+ 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
1
+ var grUser = new GlideRecord ( 'sys_user' ) ;
2
+
3
+ if ( grUser . get ( '62826bf03710200044e0bfc8bcbe5df9' ) ) {
4
+ grUser . user_name = 'test.user' ;
5
+ grUser . first_name = 'test' ;
6
+ grUser . last_name = 'user' ;
7
+ grUser . email = 'test.user@servicenow' ;
8
+ grUser . update ( ) ;
9
+ } else {
10
+ gs . info ( 'Record not found.' ) ;
11
+ }
You can’t perform that action at this time.
0 commit comments