gs.addInfoMessage not working in onBefore business rule?

Mitch Moses
Giga Expert

Trying to create a popup after this business rule runs, but it's not working.

 

(function executeRule(current, previous /*null when async*/) {
	
	// Add your code here
	var gr= new GlideRecord('cmdb_ci');
	gr.addQuery('sys_id',current.cmdb_ci);
	gr.addQuery('sys_id','!=','89c9a7130fe6bec07122abf8b1050eea');
	gr.addQuery('sys_id','!=','81c8ec22dbf13700d82851d7f496199f');
	gr.query();

	if(gr.next())
		{
		if(gr.name)
			{
			if(gr.u_linked_business_service)
				{
				current.business_service = gr.u_linked_business_service;
			}
			current.company=gr.company;
			current.location=gr.location;
	
			gs.addInfoMessage('Hello');// doesn't work
		}	
	}
	
7 REPLIES 7

Hi Mitch,

 

Can you check link once.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Like Jaspal already mentioned, try debugging your code with for example gs.info statements (Jaspal mentioned gs.log, also fine). This could shorten your search a lot, if you spot quicker where the code is stuck.

Though something I did already notice about your addQuery. Your querying a sys_id (which is unique) and also querying twice on sys_id !=. This doesn't make sence? I would say first rethink your addQuery.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

The issue I am having is that I have put the gs.log before and after my gs.addInfoMessage. The gs.log appear in the logs, but addInfoMessage doesn't pop up? Maybe it's something wrong with my setup

find_real_file.png