The CreatorCon Call for Content is officially open! Get started here.

I am using query business rule with no conditions on incident table

ServiceNow Use6
Tera Guru

Hi,

It is not giving any output to logs. Kindly help.


(function executeRule(current, previous /*null when async*/) {

	current.addActiveQuery();
	current.addQuery('priority', 1);
	current.query();
	while(current.next()){
		gs.log('The numbers are ' + current.number);
	}

})(current, previous);

 

Regards

Suman P.

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow Use6 

query business rule doesn't have access to field values hence you can't print any field value or can't access it

it's meant only to restrict based on some logic

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Sarthak Kashyap
Tera Guru

Hi @ServiceNow Use6 ,

 

If you want to use query BR then just write script like 

 

current.addQuery('priority', 1);

 

Result

SarthakKashyap_0-1760524952153.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

 

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow Use6 

query business rule doesn't have access to field values hence you can't print any field value or can't access it

it's meant only to restrict based on some logic

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank You @Ankur Bawiskar,

 

I didn't know that it will not generate output. I am stupid. It is just filtering and giving the output.

 

Regards

Suman P.

Sarthak Kashyap
Tera Guru

Hi @ServiceNow Use6 ,

 

If you want to use query BR then just write script like 

 

current.addQuery('priority', 1);

 

Result

SarthakKashyap_0-1760524952153.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak