- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 09:01 PM
I have created a BR to track our FCR in the incident table. The BR executes as expected on Default view, however when i create a incident record in the SOW it sets the wrong value. I can't figure it out why since all conditions are met. The field will correct update when the record goes from Resolved to closed, but from insert or update to Resolved it sets the value to "FCR not achieved" which should since the criteria are the same.
Here its my script for the BR:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 10:35 PM
@mcroxall - Please set the order for your business rule to 999 and check.
When the BR order is 100 then it is not setting the resolved by value when this BR is triggered from SOW. Please check.
Thanks & Regards,
Vasanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 09:33 PM
@mcroxall You have an if check at the bottom of your script.
if (
isFinalState &&
!wasOnHold &&
openedBy &&
resolvedBy &&
openedBy == resolvedBy &&
reassignmentCount === 0 &&
reopenCount === 0 &&
!isAssignedExternally
) {
The fcrValue = 'FCR Achieved'; is only set once the above if check evaluates to true.
In the above condition var isFinalState = (state == STATE_RESOLVED || state == STATE_CLOSED); is only set to true when the state is either Resolved or Closed. This will simply hold a false value for other states, due to this your if check is failing and the value is set to FCR not achieved.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 09:40 PM
but why does it work when i create a record using default view and does not work when creating a record in the SOW?
I'll try your your suggestions! thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 09:44 PM
can you try this and debug as logs are added?
(function executeRule(current, previous) {
// Define state constants
var STATE_NEW = '1';
var STATE_IN_PROGRESS = '2';
var STATE_ON_HOLD = '3';
var STATE_RESOLVED = '6';
var STATE_CLOSED = '7';
var STATE_CANCELED = '8';
var state = current.getValue('state');
gs.log('Current state: ' + state);
// Do not update FCR if state is New, In Progress, or Canceled
if (state == STATE_NEW || state == STATE_IN_PROGRESS || state == STATE_CANCELED) {
gs.log('State is New, In Progress, or Canceled. Exiting.');
return;
}
var fcrValue = 'FCR Not Achieved';
var openedBy = current.getValue('opened_by');
var resolvedBy = current.getValue('resolved_by');
var assignedTo = current.getValue('assigned_to');
var reassignmentCount = parseInt(current.getValue('reassignment_count') || '0', 10);
var reopenCount = parseInt(current.getValue('reopen_count') || '0', 10);
gs.log('Opened by: ' + openedBy);
gs.log('Resolved by: ' + resolvedBy);
gs.log('Assigned to: ' + assignedTo);
gs.log('Reassignment count: ' + reassignmentCount);
gs.log('Reopen count: ' + reopenCount);
var isFinalState = (state == STATE_RESOLVED || state == STATE_CLOSED);
gs.log('Is final state: ' + isFinalState);
// Check for On Hold history
var wasOnHold = false;
var auditGR = new GlideRecord('sys_audit');
auditGR.addQuery('documentkey', current.sys_id);
auditGR.addQuery('fieldname', 'state');
auditGR.addQuery('newvalue', STATE_ON_HOLD);
auditGR.setLimit(100);
auditGR.query();
if (auditGR.hasNext()) {
wasOnHold = true;
}
gs.log('Was on hold: ' + wasOnHold);
var isAssignedExternally = assignedTo && assignedTo != openedBy && assignedTo != resolvedBy;
gs.log('Is assigned externally: ' + isAssignedExternally);
if (
isFinalState &&
!wasOnHold &&
openedBy &&
resolvedBy &&
openedBy == resolvedBy &&
reassignmentCount === 0 &&
reopenCount === 0 &&
!isAssignedExternally
) {
fcrValue = 'FCR Achieved';
}
gs.log('FCR Value: ' + fcrValue);
current.u_first_contact_resolution = fcrValue;
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 10:09 PM
Did you see by using above script and the logs?
Did you check BR itself is triggering or not?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader