Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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