- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 12:41 PM
Got a question related to requested item. For an API we need to get the comments added into the sc_req_item and display as a status.
When we add comment to sc_req_table all comments goes to activity stream. I am able to use below code global scope (As a background script) to get activity stream and display it.
var stream = new GlideSPScriptable().getStream('sc_req_item', <sysId of ritm>);
a = JSON.stringify(stream, null, '\t');
activities = JSON.parse(a);
for( i = 0 ; i < activities.entries.length; i++ ){
gs.print(activities.entries[i].sys_created_on + " " + activities.entries[i].value);
}
However when I move the code to scoped application I get below error
"The server could not process the request. Error java.lang.RuntimeException: failed to coerce com.glide.script.fencing.ScopedGlideElement to desired type java.lang.String"
I changed to 'new global.GlideSPScriptable().getStream ' Now get error.
"The server could not process the request. Error java.lang.SecurityException: Invalid object in scoped script:[JavaClass com.glide.service_portal.widget.SPScriptable]"
Question is how to query activity stream from a scoped application. The script is running as Scriptable Rest API.
Thanks
Kannan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 01:48 PM
Thanks to Chuck I was able to answer this
so used below code
var gr = new GlideRecord("sc_req_item");
gr.addQuery('number','RITMy4999447');
gr.query();
msg=""
while (gr.next()){
gs.debug( gr.comments.getJournalEntry(-1));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 01:48 PM
Thanks to Chuck I was able to answer this
so used below code
var gr = new GlideRecord("sc_req_item");
gr.addQuery('number','RITMy4999447');
gr.query();
msg=""
while (gr.next()){
gs.debug( gr.comments.getJournalEntry(-1));
}