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
‎12-21-2016 04:59 AM
sorry to bother you again and again
When i use spModal and spUtil in main then the entire div is getting hidden
cleint scrip[t:
function (spModal,spUtil) {
var c = this;
c.action = function(state) {
c.data.op = state;
if(state == "rejected"){
c.onPrompt();
}
c.data.state = state;
c.server.update();
}
c.onPrompt = function() {
spModal.open({
title: 'Give me a comment',
message: 'Your comment please?',
input: true,
value: c.comment
}).then(function(comment) {
c.comment = comment;
c.data.comment = comment;
})
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 05:13 AM
normaly you just need spModal in the client script function, but I do not understand why it is happening, do you get any error message?
I assume you have somewhere a bug in HTML ?
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 05:17 AM
Here is the HTML code
<div class="panel panel-{{::c.options.color}} b">
<div class="panel-heading">
<h4 class="panel-title" ng-if="c.data.state == 'requested'">${This {{c.data.label}} requires your approval}</h4>
<h4 class="panel-title" ng-if="c.data.state == 'approved'">${Approved} <sn-time-ago timestamp="::c.data.sys_updated_on" /></h4>
<h4 class="panel-title" ng-if="c.data.state == 'rejected' && c.data.comment">${Rejected} <sn-time-ago timestamp="::c.data.sys_updated_on" /></h4>
</div>
<div class="panel-body">
<form ng-submit="$event.preventDefault()" class="form-horizontal">
<div ng-if="c.data.fields.length > 0">
<div ng-repeat="field in c.data.fields" class="m-b-xs" ng-if="field.value">
<label class="m-n">{{field.label}}</label>
<span ng-switch="field.type">
<div ng-switch-when="glide_date_time" title="{{field.display_value}}"><sn-time-ago timestamp="::field.value" /></div>
<div ng-switch-default >{{field.display_value}}</div>
</span>
</div>
</div>
<div ng-if="c.data.state == 'requested'" class="question">
<button type="button" name="approve" class="btn btn-success btn-question" ng-click="c.action('approved')">${Approve}</button>
<div class="spacer"></div>
<button type="button" name="reject" class="btn btn-default btn-question" ng-click="c.action('rejected')">${Reject}</button>
</div>
</form>
<div ng-if="c.data.state == 'rejected'" ng-show="c.comment">
You answered <span>{{c.comment}}</span>
</div>
</div>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 05:38 AM
Hey Amaradi
it has todo with the <div ng-if="c.data.state == 'requested'" class="question"> Line 18, you are asking if the state is requested then it should show you the button.
On the page the state is not requested I assume, as this is taking it from the server script fields state, and if there is no task requested , it wont be any button.
You can remove this if from the html or you have to be sure that there is a task and this task has the state "requested"
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 05:41 AM