Incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2024 01:19 PM
Incident form Assignment Group below create one filed "Previous Assignment Group".
User select assignment group is Service desk and save.
Again user select assignment group is Hardware Group and save , after saved
Assignment Group : Hardware
Previous Assignment Group : Service Desk automatically populate the incident form.
Using Business Rule but not working any idea help me proper code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2024 06:08 PM
@ServiceNow40 You need a Business Rule that triggers when the Assignment Group field (assignment_group) changes. The rule should store the previous value of assignment_group in a custom field called Previous Assignment Group (u_previous_assignment_group).
Hope you are using before update BR with similar to below code with enabling advance option:
// Check if the assignment_group field value has changed
if (current.assignment_group.changes() && !gs.nil(current.assignment_group)) {
// Set the u_previous_assignment_group to the previous value of assignment_group
current.u_previous_assignment_group = current.assignment_group.previousValue();
}
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2024 06:21 PM - edited 11-09-2024 06:24 PM
Hello @ServiceNow40
If working on form level then onChange client script is the solution.
You can achieve this with an onChange client script on the Assignment Group field. Here’s how:
Go to the Incident table and create an onChange client script.
Configure it to trigger when the Assignment Group field changes.
Use the script below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Set 'Previous Assignment Group' with the old value of 'Assignment Group'
g_form.setValue('previous_assignment_group', oldValue);
}
This will populate the Previous Assignment Group field with the previous value of Assignment Group whenever it changes.
Please hit like and mark it as an accepted solution.
Thank You
Juhi Poddar