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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This script Update incidents with the department of their caller
Loops through every user in the sys_user table.
For each user, finds all incidents where they are the caller (caller_id matches sys_id of the user).
For each matching incident: Copies the user's department value, Sets it on the incident's custom field u_department.

Use Case Example:

Let’s say you want each incident record to store the caller’s department, but this info is only on the user profile.
This script pulls it from the user and updates all related incident records.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var userGr = new GlideRecord('sys_user');
userGr.query();
while (userGr.next()) {
var incGr = new GlideRecord('incident');
incGr.addQuery('caller_id', userGr.sys_id);
incGr.query();
while (incGr.next()) {
incGr.u_department = userGr.department; // Assuming custom field u_department
incGr.update();
}
}
Loading