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

Dont see any issue with the script. Can you try below?

 

 

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

I agree with you. I ran it a few time. I did try the code the other way but same result. Find below the screenshot after running the above script.Account_Screenshot.png

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

WOW. Thank you for answering the question.


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