Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Calling Business Rule from Client Script!

tarandeep1982
Kilo Explorer

Hi All,

As I m new to service-now...I m unable to call Business Rule from Client Script...

As the code for calling BR which I have written is:-

function doMyBusinessRule() {
gs.log('Warning');
var agg = new GlideAggregate('u_some_data1');
agg.addAggregate("COUNT");
agg.query();
var answer = 'false';
if (agg.next()) {
answer = agg.getAggregate("COUNT");

if (answer > 0){
answer = 'true';
}
else{
answer = 'false';
}
}
return answer;
}

And Client Script code as follows:-

function onLoad() {
//Type appropriate comment here, and begin script below

var answer = AJAXEvaluateSynchronously("doMyBusinessRule()");
alert("HI "+" "+answer);
if(answer == 'true') {
alert('Found matching incident');
}
}

Please reply whoever knows this.

Thanks & Regards
Tarandeep Singh

1 REPLY 1

Mark Stanger
Giga Sage

Check this out...

http://wiki.service-now.com/index.php?title=Security_options#Enabling_the_AJAXEvaluate_Processor

It's probably better for you to use 'GlideAJAX' to do this...

http://wiki.service-now.com/index.php?title=GlideAjax