- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2020 11:06 PM
I have an UI action "Create Incident" in RITM table. A pop up opens which prompts the user to enter comment. It creates an Incident once the user enter the comments and click OK. The Incident gets associated with the RITM. This is working as expected. Thanks to
But the same functionality is not working in our Agent workspace. The pop up opens fine. The Incident is also getting created successfully. But the Incident is not getting associated with the RITM.
Here is the UI Action script
Script:
function createIncident() {
var number = g_form.getValue("number");
var sysId = g_form.getUniqueValue();
var gDialog = new GlideDialogWindow('create_Incident');
gDialog.setSize('600','600');
gDialog.setPreference('sysparm_sysID', sysId);
gDialog.setPreference('sysparm_number', number);
gDialog.setTitle('Create Incident');
gDialog.render();
}
Workspace CLient script:
function onClick(g_form) {
var table = g_form.getTableName();
var sysId = g_form.getUniqueValue();
var url = "/create_Incident.do?targetTable=" + table + "&targetId=" + sysId + "&source=agent_workspace";
g_modal.showFrame({
url: url,
title: 'Create Incident',
size: 'xl'
});
UI Page:
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<!-- Get values from dialog preferences passed in -->
<g:evaluate var="jvar_sysId" expression="RP.getWindowProperties().get('sysparm_sysID')" />
<g:evaluate var="jvar_num" expression="RP.getWindowProperties().get('sysparm_number')" />
<!-- Set up form fields and labels -->
<input type="hidden" name="ritmSysId" id="ritmSysId" value="${jvar_sysId}"/>
<input type="hidden" name="ritmNum" id="ritmNum" value="${jvar_num}"/>
<input type="hidden" name="comments" id="comments" value=""/>
<table width="100%">
<tr>
<td>
<!-- Comments text field (Contains comments from originating record as a default) -->
<g:ui_multiline_input_field name="dial_comments" id="dial_comments" label="comments" value="${jvar_comments_text}" mandatory="true" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr id="dialog_buttons">
<td colspan="2" align="right">
<g:dialog_buttons_ok_cancel ok="return submitRecord();" cancel ="return OnCancel();"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function OnCancel() {
// var c = gel('cancelled');
// c.value = "true";
GlideDialogWindow.get().destroy();
// return false;
}
function submitRecord() {
var comments = gel("dial_comments").value;
comments = trim(comments);
if (comments == "") {
//If comments are empty stop submission
alert("Please provide comments to submit the dialog.");
return false;
}
gel("comments").value = comments;
return true;
}
Processing Script:
var createInc = new GlideRecord("incident");
createInc.initialize();
createInc.parent = ritmSysId;
createInc.u_source = "service_request";
createInc.caller_id = gs.getUserID();
createInc.short_description = "Incident raised for Requested Item " + ritmNum;
createInc.description += "An Incident has been raised for Requested Item " + ritmNum + " with the following comment:<br />" + comments;
createInc.insert();
response.sendRedirect("sc_req_item.do?sys_id=" + ritmSysId);
gs.addInfoMessage("Incident "+ createInc.number+" is created successfully");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 02:17 AM
you are not sending the correct parameter name in the URL
In UI action workspace client script you are sending targetId but in UI page you are checking sysparm_sysID
ensure the parameter name is same so that it works well from both native and agent view
please update workspace client script as below
function onClick(g_form) {
//var table = g_form.getTableName(); // this is not required
var sysId = g_form.getUniqueValue();
var url = "/create_Incident.do?targetTable=" + table + "&sysparm_sysID=" + sysId + "&source=agent_workspace";
g_modal.showFrame({
url: url,
title: 'Create Incident',
size: 'xl'
});
}
Also you are not using this line so remove this
<input type="hidden" name="ritmNum" id="ritmNum" value="${sysparm_number}"/>
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 01:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 02:17 AM
you are not sending the correct parameter name in the URL
In UI action workspace client script you are sending targetId but in UI page you are checking sysparm_sysID
ensure the parameter name is same so that it works well from both native and agent view
please update workspace client script as below
function onClick(g_form) {
//var table = g_form.getTableName(); // this is not required
var sysId = g_form.getUniqueValue();
var url = "/create_Incident.do?targetTable=" + table + "&sysparm_sysID=" + sysId + "&source=agent_workspace";
g_modal.showFrame({
url: url,
title: 'Create Incident',
size: 'xl'
});
}
Also you are not using this line so remove this
<input type="hidden" name="ritmNum" id="ritmNum" value="${sysparm_number}"/>
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 03:15 AM
Hi Ankur,
It is working very well. Thanks for your help.
I'm using this line to paste the RITM number in "Description" field in Incident. So I will keep it..
<input type="hidden" name="ritmNum" id="ritmNum" value="${sysparm_number}"/>
Now my final script is
function onClick(g_form) {
var table = g_form.getTableName();
var number = g_form.getValue("number");
var sysId = g_form.getUniqueValue();
var url = "/create_Incident.do?targetTable=" + table + "&sysparm_sysID=" + sysId + "&sysparm_number=" + number + "&source=agent_workspace";
g_modal.showFrame({
url: url,
title: 'Create Incident',
size: 'xl'
});
}
Best Regards,
Ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2020 03:22 AM
Okay nice.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2020 03:27 PM
I have a similar issue where an email UI action using client template that works from the form but not from Agent Workspace. Not sure what needs to be done differently for UI Actions in agent workspace.
Below code works from Interaction form but not from Agent Workspace
function showEmailTemplate(){
var id = g_form.getUniqueValue();
var url = 'email_client.do?sysparm_table=interaction&sysparm_sys_id='+id+'&email_client_template=MEmail_Template';
popupOpenEmailClient(url);
}
Any help will be appreciated!