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

Jaspal Singh
Mega Patron
Mega Patron

Hi Mitch,

(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())
		{
gs.log('Record found');
		if(gr.name)
			{
gs.log('Name is ',gr.name);
			if(gr.u_linked_business_service)
				{
gs.log('BS is ',gr.u_linked_business_service);
				current.business_service = gr.u_linked_business_service;
			}
			current.company=gr.company;
			current.location=gr.location;
	current.update();
			gs.addInfoMessage('Hello');// doesn't work
		}	
	}

 

Try using something as above & check for logs.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

 

I got this find_real_file.png

Thanks Mitch that helps.

 

Can you replace 

current.company=gr.company;
			current.location=gr.location;
	current.update();
			gs.addInfoMessage('Hello');// doesn't work

 

with

 

gs.log('Company is ',gr.company);
current.company=gr.company;
			current.location=gr.location;
	current.update();
			gs.addInfoMessage('Hello');// doesn't work
gs.log('Infomessage displayed');

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

I get it in the logs, but don't get the popup on the new incident creation I am on 

find_real_file.png