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

How to add a comment/work_note using script on Service Portal

JC S_
Mega Guru

We are trying to put a button on ticket form of Service Portal that once clicked will add an additional comment or a work note to the current incident being viewed.

We tried the following code on our if statement when the button is clicked but nothing is being added on the incident:

gr.setValue('work_notes', "The caller did not feel that this issue was resolved.");

gr.setValue('comments', "Please reopen this incident.");

gr.setValue('state', 2);

However the code on line 3 is working just fine (this if statement is inside another if statement which checks if the current table is the incident table).

1 ACCEPTED SOLUTION

Ujjawal Vishnoi
Mega Sage

Hi Jimboy,



You can replace the code with either of the below blocks.



gr.work_notes="The caller did not feel that this issue was resolved.";  


gr.comments= "Please reopen this incident.";  


gr.setValue('state', 2);  




gr['work_notes'].setJournalEntry("The caller did not feel that this issue was resolved.");


gr['comments'].setJournalEntry("Please reopen this incident.");


gr.setValue('state', 2);  



Both will work.



Hope this helps.



Regards


Ujjawal


View solution in original post

7 REPLIES 7

Thanks. Though the second option you mentioned can be more short by using what jaspalsinghchot mentioned above:



gr.comments.setJournalEntry('Please reopen this incident.');


I tried with below piece of code but its still not reflecting in incident..only the sys_journal_field is updated.. 

var gr=new GlideRecord('incident');
gr.setWorkflow(false);
if(gr.get('05b10fd9db9c3300b75573278c9619b8'))

gr['comments'].setJournalEntry("Please reopen this incident.");
gr.update();

 

 

Joe72
Tera Contributor

setWorkflow(false) prevents journal fields from being updated sadly.