search for Text in Business Rules

allen_pitts
Giga Expert

Hello Implement,

 


When the assignee is changed on a project task the project short description was changed
on several projects.
In the System Log Statements an entry with Message
'Project found - OPS0000137 Test 140703 10:00 Ops Project: OPS0000151 - PArent SCHEDULE - 8-5 weekdays excluding holidays'

 

was found that has not previously appeared during testing. It is sumised that the change and the message in
log was written by a business rule.

After searching several of the 952 businesss rules in our instance a method for searching the text in business rules
was found

Search for Text in Business Rules - ServiceNow Wiki

 

 


Substituted the string 'PArent SCHEDULE' as shown in code below
Got
Javascript compiler exception: missing ) after condition (; line 10) in:

 

 

 


Not sure what is causing the error

 

Thanks

 

Allen Pitts
LHP Hospital Group

 

+++++++++++++++++beginning of code++++++++++++++++++

findit('PArent SCHEDULE');

 

function findit(str) {

 

var scr = "";

var gr1 = new GlideRecord('sys_script');

gr1.query();

while (gr1.next()) {

  scr = gr1.script.toString();

  if (scr.indexOf(str) > -1) {

      gs.addInfoMessage(gr1.name);

  }

}

 

}

 

+++++++++++++++++end of code++++++++++++++++++

1 ACCEPTED SOLUTION

ohhgr
Kilo Sage
Kilo Sage

Hi Allen,



Don't think there is anything wrong with the function as such.



Also you can find the business rule using the breadcrumbs in the list layout.



Capture.JPG




Thanks,


Mandar


View solution in original post

4 REPLIES 4

ohhgr
Kilo Sage
Kilo Sage

Hi Allen,



Don't think there is anything wrong with the function as such.



Also you can find the business rule using the breadcrumbs in the list layout.



Capture.JPG




Thanks,


Mandar


solutioningnow
Giga Guru

Hi Allen,



I have tired the same script in my instance and its working fine.. and as suggested by Mandar, you can find the business rule using filters.



Please mark answer as correct/helpful, if it was really helpful.



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/


Hello Solutioner,



Could you please copy
the code you ran so I can
try it in my instance.



Thanks



Allen


Hello Allen,



I tired below code:



findit('PArent SCHEDULE');



function findit(str) {


var scr = "";


var gr1 = new GlideRecord('sys_script');


gr1.query();


while (gr1.next()) {


  scr = gr1.script.toString();


  if (scr.indexOf(str) > -1) {


      gs.addInfoMessage(gr1.name);


  }


}


}



Just FYI, if you see code in wiki you can see below line


if (scr.indexOf(str) > -1) { -- Because of this line you are getting issue.



Above mention code will work



Please mark answer as correct/helpful, if it was really helpful.



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/