Skip to content

Commit d5b4592

Browse files
kmxokmxoLacah
authored
Background scripts (#1069)
* URL Parameter Use Case * update background scripts folder * fixing * background scripts * Delete Catalog Client Script/Set fields from URL Parameter 2/CatalogClientScript.js * Delete Catalog Client Script/Set fields from URL Parameter 2/KMXOUtils.js * Delete Catalog Client Script/Set fields from URL Parameter 2/UtilsAjax.js * Delete Catalog Client Script/Set fields from URL Parameter 2/readme.md --------- Co-authored-by: kmxo <[email protected]> Co-authored-by: Laszlo <[email protected]>
1 parent 3149aef commit d5b4592

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}

0 commit comments

Comments
 (0)