- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 01:20 AM - edited 09-29-2023 01:29 AM
We need a TASK ticket created to Account Management team when changes are made to below fields in user’s profile.
- Division
- Department
- Title
Ticket should contain both the old and new details.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 01:45 AM
Hi @divyal09 ,
You can write Business Rule on sys_user table, below are the steps:
-
Create a Business Rule: Create a Business Rule on the
sys_user
table. This Business Rule will trigger whenever a record is updated, specifically when changes are made to the fields you mentioned (Division, Department, Title). -
Configure the Condition: In the Business Rule, set up a condition that checks if any of the specified fields have changed. You can use the
previous
andcurrent
objects to compare the old and new values. -
Create a Task: If the condition is met (i.e., changes to the specified fields are detected), create a new task record. You can use a script to fill in the details of the task, including the old and new values of the fields.
Here's an example of what the Business Rule script might look like:
(function executeRule(current, previous /*null when async*/) {
// Check if Division, Department, or Title fields have changed
if (
current.division != previous.division ||
current.department != previous.department ||
current.title != previous.title
) {
// Create a new task record
var task = new GlideRecord('task');
task.initialize(); // Initialize a new task record
// Set task details
task.short_description = 'User Profile Update';
task.description = 'Changes detected in user profile:\n';
task.description += 'Old Division: ' + previous.division + '\n';
task.description += 'New Division: ' + current.division + '\n';
task.description += 'Old Department: ' + previous.department + '\n';
task.description += 'New Department: ' + current.department + '\n';
task.description += 'Old Title: ' + previous.title + '\n';
task.description += 'New Title: ' + current.title + '\n';
// Set the assignment group and other task details as needed
task.assignment_group.setDisplayValue('Account Management');
// Insert the task record
task.insert();
}
})(current, previous);
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 01:45 AM
Hi @divyal09 ,
You can write Business Rule on sys_user table, below are the steps:
-
Create a Business Rule: Create a Business Rule on the
sys_user
table. This Business Rule will trigger whenever a record is updated, specifically when changes are made to the fields you mentioned (Division, Department, Title). -
Configure the Condition: In the Business Rule, set up a condition that checks if any of the specified fields have changed. You can use the
previous
andcurrent
objects to compare the old and new values. -
Create a Task: If the condition is met (i.e., changes to the specified fields are detected), create a new task record. You can use a script to fill in the details of the task, including the old and new values of the fields.
Here's an example of what the Business Rule script might look like:
(function executeRule(current, previous /*null when async*/) {
// Check if Division, Department, or Title fields have changed
if (
current.division != previous.division ||
current.department != previous.department ||
current.title != previous.title
) {
// Create a new task record
var task = new GlideRecord('task');
task.initialize(); // Initialize a new task record
// Set task details
task.short_description = 'User Profile Update';
task.description = 'Changes detected in user profile:\n';
task.description += 'Old Division: ' + previous.division + '\n';
task.description += 'New Division: ' + current.division + '\n';
task.description += 'Old Department: ' + previous.department + '\n';
task.description += 'New Department: ' + current.department + '\n';
task.description += 'Old Title: ' + previous.title + '\n';
task.description += 'New Title: ' + current.title + '\n';
// Set the assignment group and other task details as needed
task.assignment_group.setDisplayValue('Account Management');
// Insert the task record
task.insert();
}
})(current, previous);
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 02:07 AM
Thanks!!! It worked.