- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2017 08:39 AM
We've set up a business rule to automatically migrate records from a custom application table to the incident table when the assignment group changes to one of our IT groups. It works great for single records but if the user changes multiple records from the table view (via ctrl+click and drag), the record keeps the number from the old table rather than creating a new incident number.
The lines where we change the number and migrate are:
//Set caller_id
current.caller_id = current.u_requested_for_usr;
//clear number
current.number = '';
//Migrate Task
current.sys_class_name='incident';
//Redirect to new Task
action.setRedirectURL(current);
//Update Current Record and get SysID
var inc_sysid = current.update();
//Query for the new record by SysID
var new_inc;
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',inc_sysid);
inc.setLimit(1);
inc.query();
while (inc.next()) {
//Update HR Payroll Inquiry Number
inc.u_previous_number = previous_number;
inc.incident_state = 2;
inc.state = 2;
//Set Migrated to true send email notification
inc.u_migrated = true;
inc.active = true;
//Set Requested For User with Caller
inc.caller_id = current.caller_id;
new_inc = inc.update();
}
This all seems to work even running on multiple records at once. Only the number field is affected.
The rule runs as a 'before' script.
We wanted to know if there's something happening in the business rule execution that would affect the number being set correctly.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 08:47 AM
For anyone who has an issue with Business rules breaking when a record is updated on the list view, the issue was with this line:
action.setRedirectURL(current);
This is supposed to redirect to the new form but this code breaks when run from the list view. Removing this line solved our problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2017 08:47 AM
For anyone who has an issue with Business rules breaking when a record is updated on the list view, the issue was with this line:
action.setRedirectURL(current);
This is supposed to redirect to the new form but this code breaks when run from the list view. Removing this line solved our problem.