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

Jaspal Singh
Mega Patron
Mega Patron

Hi Jimboy,



Try using below code,



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



Thanks,


Jaspal Singh



Hit Like or Correct on the impact of response.


Its works \o/

anurag92
Kilo Sage

Set Value won't work in this case.



You can use:


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


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