Fix Script giving an error "Cannot disable before query business rule(s) across..."

Community Alums
Not applicable

ServiceNow Experts,

 

I have written a below Fix Script in my PDI to test out some functionality:

___________________________________

var accRegCode;
var strShorDesc;
var strAccountName;

var grAcct = new GlideRecord('customer_account');
var grCase = new GlideRecord('sn_customerservice_case');
// grAcct.orderByDesc('sys_updated_on');
grAcct.query();
while(grAcct.next()){
strAccountName = grAcct.getDisplayValue('name');

accRegCode = grAcct.getDisplayValue('registration_code');
grCase.setWorkflow(false);
grCase.addQuery('account', strAccountName);
grCase.query();
while(grCase.next()){
strShorDesc = grCase.getDisplayValue('short_description');
grCase.setValue('short_description', strShorDesc+' : '+accRegCode);
grCase.setWorkflow(false);
grCase.update();
}
}

_________________

I am getting below error when I go to Progress worker:

Cannot disable before query business rule(s) across scope boundaries (current scope: rhino.global table scope: sn_customerservice)

 

Any thoughts?

 

Thanks,

MK

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Here's the solution:

___________________

var accRegCode='';
var strShorDesc='';
var strAccountName='';

var grAcct = new GlideRecord('customer_account');
// grAcct.orderByDesc('sys_updated_on');
grAcct.query();
while(grAcct.next()){
var grCase = new GlideRecord('sn_customerservice_case');
strAccountName = grAcct.getDisplayValue('sys_id')+'';
accRegCode = grAcct.getDisplayValue('registration_code')+'';
grCase.addQuery('account', strAccountName);
grCase.query();
while(grCase.next()){
strShorDesc = grCase.getDisplayValue('short_description');
grCase.setValue('short_description', strShorDesc+' : '+accRegCode);
grCase.setWorkflow(false);
grCase.update();
}
}

______________________________

I have to use sys_id for querying at the Case table. Attached screenshot.

 

Thanks for all you help.

 

MKSolution.PNG

View solution in original post

8 REPLIES 8

Kartik Choudha1
Tera Guru

Hey,

 

You may try running it into the table scope which is 'sn_customerservice'.

Change your scope of fix script or create a fix script in 'sn_customerservice' scope.

 

Why because the fix script you are running on table is from different scope and your fix script or you are in a different scope. That's why query BR written for that table is not getting disabled by setWorkflow(false)

 

Hope this helps!

Regards,

Kartik

Community Alums
Not applicable

I ran in Customer Service and Global scope but gives me the same error.

SanjivMeher
Kilo Patron
Kilo Patron

Can you try with below script in Customer Service Scope?

 

var accRegCode;
var strShorDesc;
var strAccountName;

var grAcct = new GlideRecord('customer_account');
// grAcct.orderByDesc('sys_updated_on');
grAcct.query();
while(grAcct.next()){
var grCase = new GlideRecord('sn_customerservice_case');
strAccountName = grAcct.getDisplayValue('name');
accRegCode = grAcct.getDisplayValue('registration_code');
grCase.addQuery('account', strAccountName);
grCase.query();
while(grCase.next()){
strShorDesc = grCase.getDisplayValue('short_description');
grCase.setValue('short_description', strShorDesc+' : '+accRegCode);
grCase.setWorkflow(false);
grCase.update();
}
}

 


Please mark this response as correct or helpful if it assisted you with your question.

Community Alums
Not applicable

Thanks. I see the change which you had made.

It ran but it is fetching only one account's registration code and pasting in all the Case's Short Description. Looping is not refreshing(means from 2nd record onwards) it is not taking new Account's Registration Code.

Thoughts?