Service Portal building conversation widget: Function from "API Server Side scoped" class: GlideSPScriptable.getStream(String table, String sysId) does not work as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2016 06:05 AM
For a client I am trying to modify the "Ticket Conversation" widget to display Activity Stream for a custom table in a similar way as the Service Portal demo does for Incidents.
I have created a custom table with journal fields and made table "auditable" in sys_dictionary. In the form (client) for the custom table the Acivity stream works as expected and produces a log for all activities.
I would now like to present the activity stream in the new Service Portal. The OOB widget "Ticket Conversations" does this in a neat way for some of the posts in the activity stream, I would like to modify it to work for a custom table and also add the possibility to see Historic changes to fields (not in the widget today).
My problem is that it seems to work ok when I extend a task table and point the widget to a record from the extended table. The issue in this case is that for this custom table we do not extend Task table. Result is that I am not able to retrieve the Activity Stream in the widget.
My question is if there is any setting on table level you have to perform to retrieve the activity stream.
If not, I believe there is a issue with the $sp.getStream(String table, String sysId) function from the API (https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&type=server&scoped=true&to=method_class...).
It seems this function does not return the Stream Object as expected.
I have understood that the issue is on row #55 in "Ticket Conversation" widget Server Script. The row is: data.stream = $sp.getStream(data.table, data.sys_id);
This function call (when run on a record in a table extending Task) return the following object Object[display_value,sys_id,short_description,number,entries,user_sys_id,user_full_name,user_login,label,table,journal_fields]
When run on a table NOT extending Task it return the following: Object[table, sys_id]
If anyone has encountered any problems or has anoher solution to present the Activity Stream in Service Portal in a nice way, please comment.
Steps to reproduce issue:
- Create custom table (u_test_table)
- Add a "Journal" column and a "Journal Input" field to table
- Confirm Table is marked as "Auditable" in sys_dictionary
- Confirm Table is marked as "Live Feed" = true
- Install Service Portal for Enterprise plugin
- Copy "Ticket Conversations" widget to "My Ticket Conversations"
- Add "My Ticket Conversation" to a new page
- Access the page https://my_instance.service-now.com/sp?id=new_page&sys_id=MY_TICKET_SYSID&table=u_test_table
Result: Conversations for ticket is not shown. I have made the same steps but instead creating a custom table extending "task" table. If I do this the conversation is shown.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 12:31 AM
Hi Peter
I am trying to do the same with already existing table "Outage" and Outage also has no extended table.
Did you get success to this?
any solution?
Thanks
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 01:29 AM
Hi Elias,
I got the following response from HI (reported as an issue):
Issue Summary: Function from the "API Server Side scoped" class:GlideSPScriptable.getStream(String table, String sysId) does not work as expected.
Reason: After revising the code, our development team explained to use that the $sp.getStream(table, sys_id) function only works for tables that extend Task, so it is in fact working correctly.
Solution Proposed: I created a documentation request (DOC15535) and attached it to this incident, so that there can be better references for this specific function and it's limitations. I apologize for the inconvenience.
It seems you have to extend taks table to use the $sp.getStream(table, sys_id) function.
I guess you have to develop your own solution to make a "ticket conversation" widget work for tables not extending task.
If you find alternate solutions to this, please keep us posted..
Best regards,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2016 01:33 AM
Thanks for your answer.
I will try to develop or find a different way to get Journal Fields shown on my widget but I think it is not possible to extend a table that already exists afterwards.
Thanks
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2016 02:40 AM
Hi Peter
I wasnt able to build exactly the same because as you said my table has no extended. But i was able to build something similar without the timeline.
I build a page with 2 widgets. one is in the middle and the other on the right side.
On the right side I just Glide Record all table details (Label and Value) of the fields.
In the Middle I retreive the Comments Journal Field I split it and then in the HTML Part I just add this comment value into a HTML <pre> tag.
now it will take the same view as in the Table form on the ticket.
this will do our request.
If still I find a way to show it as a conversation will keep you post it.
thanks
Elias