Adding a field to the Ticket Conversations Widget in Service Portal

shawn_h
Tera Guru

Hi folks,

Looking for a bit of help in adding a field to the Ticket Conversations Widget in the Service Portal.

Ideally, I'd like to populate "close_notes" from a resolved incident, so the user can see what action was taken on resolution.

I've cloned the OOB Ticket Conversations Widget, but I'm at a bit of a loss on how to proceed with building the field into a new entry, as it looks like it's only set up to easily add/remove journal fields, and it's a bit past my scripting ability.

Alternatively, if i used a business rule to copy the close notes into one of the Journal fields so it displayed this way, I'd have to suppress a notification, which isn't ideal and thus isn't my preferred solution.

Would anybody be able to help out please?

1 ACCEPTED SOLUTION

Nia McCash
Mega Sage
Mega Sage

Hi Shawn, 

This is a quick attempt and is far from a complete solution but perhaps it can give you some ideas in the right direction...

I copied the OOB Ticket Conversation Widget and copied the HTML code that represents an entry in the conversation (lines 53-74) to show the close notes. I've commented out lines 61-67 because I didn't want to go into the complexities of figuring out when the close note was posted.  If you'd like that, hopefully you can do that on your own: 

find_real_file.png

In the Server script, I've added a line of code to get the close notes from the ticket.  You'll want to add to this to only fetch the close notes if the ticket is an incident and only if the ticket is closed, and perhaps some other error checks: 

find_real_file.png

With the above, I get something that looks a little like this:

find_real_file.png

 

View solution in original post

15 REPLIES 15

Also, tried this but failed.  can you attach TXT

I have also had trouble with this code.  The text would be very helpful.  Thanks!

I don't recall what version I tested the above code with. 

I see in Orlando the Ticket Conversation widget code has changed significantly so the above instructions will no longer work.  You may want to pose a new question for this indicating for which version you need this to work.

Hi Nia,

thanks for sharing your solution.  I am trying to do something similar but with the "State" field.  When the state changes, I want to show the activity in the portal like it would show in the backend.  I've cloned the "Ticket Conversations" widget and am attempting to mimic what you did...do you think it should work for the State field?  Thanks.  

Hi Patrick,

As long as you can get the data in the server script, you can display it as part of the widget. The question is: where would you get the data for state changes? You could query the sys_audit table but not sure this is advisable.   

Also, as mentioned above, the answer I provided was based on a previous version of ServiceNow and the widget code has changed considerably since then.