Business Rule does not work on Form Load

farci
Mega Expert

Hi All,

I have two tables, Exception and Service Request. I have written a Business Rules that update the exception id and exception status in the incident table. Basis on the reference number.

This BR works only when I have exception created first and Service Request created next for the same reference number/SR ID. But It does not work when it is vice versa. I want it to work on both the cases.

Below are the screenshot and scripts for your reference.

Service Request (Exception ID and Exception Status) gets auto update basis on BR

find_real_file.png

Exception Table (Reference Number is looked in this table) if it is a match then it gets populated in the Service Request table.

find_real_file.png

find_real_file.png

find_real_file.png

Script

(function executeRule(current, previous /*null when async*/) {

var extracting = new GlideRecord('x_isgi_isg_governa_isg_pm_sla_exception');

extracting.addQuery('reference_number',current.sr_id);

extracting.addQuery('service_month',current.service_month);

extracting.query();

if(extracting.next()){

current.excep_id = extracting.sys_id;

current.excep_status = extracting.status;

}

//current.update();

})(current, previous);

Appreciate your input and early response.

Regards,

Narmi

1 ACCEPTED SOLUTION

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

A business rule is per table, do you have 2 BRs , one for each table?


View solution in original post

2 REPLIES 2

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

A business rule is per table, do you have 2 BRs , one for each table?


Hi Sergiu,



I have one BR in Service Request Table. I do not have any BR in Exception Table from where the lookup is happening into the Service Request Table.



Exception Table is a single source which I am trying to connect to all other tables that I have.



In all the below tables I have written BR   to update exception if any tracked.



In ideal scenario user raises an exception anytime during the month and at the end of month user submits below tables with data filled in it. While validating the data if there are any misses those missing would have received an exception. Therefore It auto pics feeds from exception table.



In other cases if user has submitted the data filled tables (any below tables) then raises an exception for the miss. The exception approved/rejected does not get updated in the data tables (any tables from below). This is what my BR currently not doing.



Incident
Service Request
Change
Problem
Availability Details
Batch Analysis
Backup
Availability Check
Forecast
Rework
Service Desk
File Restoration
RCA
Asset Inventory
Project Delivery
Reporting
Patching
Staffing
Defect-Backlog
Supplier Personnel
SOW


Thanks for your response.



Regards,


Narmi