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.

View solution in original post

9 REPLIES 9

@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.

Hi @jaheerhattiwale ,

 

It is not for single record. I have lot of records from incident table

@sriram7 But from business rule on request table you have to update only that incident from which it is created right?

HI@sriram7 

I'm a bit confused. Maybe I got it wrong.

 

" I need to populate a message saying Your Incident is converted to Request : REQxxxxxxx "

means that populate the "Additional comments" field of incident  ? and doesn't mean showing a message on the page ater insert?

 

If yes , just use  

 

gr.comments  = "Your Incident is converted to Request : " + current.number;

 

 

And I can't understand why you are using a br to trigger this.

why not do like this.

In the ui action , create a  sc_req_item record.

After the record is created,update the incident record and show a message?

 

 

 

 

 

 

 

 

@sriram7 

 

And there is one more thing to note.

 

The below code only updates 1 record althought the query retuns many records.

Don't forget to  change "if" to  "while"..

 

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();

 

}