How to populate message in Additional Comments in Incident Form

sriram7
Tera Contributor

Hi Team,

 

I have UI Action in Incident Form. When I click on that it is converting to request. once I submitted that request, I need to populate a message saying Your Incident is converted to Request : REQxxxxxxx 

 

How Can I achieve this

1 ACCEPTED SOLUTION

@sriram7You can try below code:

 

var gr = new GlideRecord('incident');
gr.addQuery("sys_id", "<INCIDENT SYS ID HERE>");
gr.query();

if(gr.next()){
gs.addInfoMessage('Your Incident is converted to Request : current.number');  
gr.state = '3';
gr.resolution_code = 'solved';
gr.comments = "Your Incident is converted to Request: "+current.number;
gr.update();

}
 
 
Please mark as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

9 REPLIES 9

Ankita19
Tera Guru
Tera Guru

Hi, If you want to show msg at time of submit you can use  an onSubmit script . Create the onSubmit script and use this code "g_form.addInfoMessage("message here").

I hope this helps

sriram7
Tera Contributor

Hi,

 

I need to update this using Business Rule.

I have written after Insert business rule on sc_req_item table.

In this I need to populate Additional Comment message, State, Resolution Fields.

 

Var gr = new GlideRecord('incident');

gr.query();

if(gr.next())

{

   gs.addInfoMessage('Your Incident is converted to Request : current.number');   

  gr.state = '3';

  gr.resolution code = 'solved'; 

gr.update();

}

 

I have written this code for updating Additional Comments, state and Resolution code, But it is not working

newhand
Mega Sage

HI @sriram7 

If your UI Action runs on client side , please use the below sample code.

 

g_form.addInfoMessage('The top five fields in this form are mandatory');

 

 

If server side, please use this.

 

gs.addInfoMessage('start must be before end');

 

 

Please mark my answer as correct and helpful based on Impact.

sriram7
Tera Contributor

Hi,

 

I need to update this using Business Rule.

I have written after Insert business rule on sc_req_item table.

In this I need to populate Additional Comment message, State, Resolution Fields.

 

Var gr = new GlideRecord('incident');

gr.query();

if(gr.next())

{

   gs.addInfoMessage('Your Incident is converted to Request : current.number');   

  gr.state = '3';

  gr.resolution code = 'solved'; 

gr.update();

}

 

I have written this code for updating Additional Comments, state and Resolutin code, But it is not working