Agent Workspace Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 02:28 PM - edited 02-19-2025 02:44 PM
Hello,
I'm trying to create a UI action that export an HR case record in both the case form in the native UI and Agent Workspace. The UI action works correctly in the native UI but does not function properly in Agent Workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:13 AM - edited 02-18-2025 01:14 AM
here is my script include (client callable):
var validateService = Class.create();
validateService.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getViewName: function() {
var hrService = this.getParameter('sysparm_service');
var viewName = '';
var grService = new GlideRecord("sn_hr_core_service");
grService.get(hrService.toString());
if(grService.name == "Extra"){
viewName = 'extra_view';}
else {
viewName = 'old_extra_view';}
return viewName;},
type: 'validateService'
});
Note: this is working as expected in native.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 02:11 AM
Hi @Michael94
I just found that the table name which you've used in the workspace UI script is incorrect.
OOB HR case table name is "sn_hr_core_case" but you are using "sn_hr_case".
Could you please validate the table name?
var url = instanceURL +'sn_hr_core_case.do?PDF&sys_id=' + sysparm_sys_id+'&sysparm_view='+sysparm_view;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 06:37 AM
Yes, I had fixed it earlier and that's not the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 09:10 PM
@Ankur Bawiskar and @J Siva, I think the issue lies in the Ajax call within the Workspace client script, as it is not returning any view value. If I remove the Ajax call and instead directly specify a view (e.g., viewName = 'extra_view') while handling the PDF process entirely within the workspace client script, how should the script be structured?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 09:25 PM
why not use getReference with callback instead of GlideAjax
OR
You can use GlideRecord with call back
function onClick(g_form) {
var hrService = g_form.getValue('hr_service');
var gr = new GlideRecord("sn_hr_core_service");
gr.addQuery("sys_id", hrService);
gr.query(checkRecord);
function checkRecord(gr) {
if (gr.next()) {
var sysparm_view = '';
if (gr.name.toString() == "Extra") {
sysparm_view = 'extra_view';
} else {
sysparm_view = 'old_extra_view';
}
var sysparm_sys_id = g_form.getUniqueValue().toString();
var url = '/' + instanceURL + 'sn_hr_core_case.do?PDF&sys_id=' + sysparm_sys_id + '&sysparm_view=' + sysparm_view;
top.window.open(url, '_blank');
}
}
OR using location.hostname
function onClick(g_form) {
var hrService = g_form.getValue('hr_service');
var gr = new GlideRecord("sn_hr_core_service");
gr.addQuery("sys_id", hrService);
gr.query(checkRecord);
function checkRecord(gr) {
if (gr.next()) {
var instanceURL = "https://" + location.hostname + "/";
var sysparm_view = '';
if (gr.name.toString() == "Extra") {
sysparm_view = 'extra_view';
} else {
sysparm_view = 'old_extra_view';
}
var sysparm_sys_id = g_form.getUniqueValue().toString();
var url = instanceURL + 'sn_hr_core_case.do?PDF&sys_id=' + sysparm_sys_id + '&sysparm_view=' + sysparm_view;
top.window.open(url, '_blank');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader