- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 10:52 PM
Hi Experts.
I'm trying to custom modal box for review additional comments with [Save] UI Action. (button)
I expected to Serverside Script will run after Workspace Client Script running But it doesn't work. (debug alert does not appeared)
As above I need to change OOTB [Save] action and modify script like below
Script:
if (typeof window == 'undefined')
afterCommentCheckModal();
function afterCommentCheckModal() {
current.update();
// Track number of cases that are updated via CSM Agent Workspace
var csmWorkspaceUAUtil = new sn_csm_workspace.CSMWorkspaceUAUtil();
csmWorkspaceUAUtil.updateCase(current.sys_id);
alert('!!!!!!!!!!'); // **for debug alert**
}
Workspace Client Script:
function onClick(g_form) {
var act = g_form.getActionName();
alert(act);
var comm = g_form.getValue('comments');
var fields = [{
type: 'textarea',
name: 'comments',
label: getMessage('comments'),
value: comm
}];
if (comm) {
g_modal.showFields({
title: "check additional comment",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('comments', fieldValues.updatedFields[0].value);
g_form.submit(act);
});
} else {
g_form.submit(act);
}
}
cf. I've already checked community questions & Knowledges below
Client & Server Code in One UI Action - ServiceNow Guru
gsftSubmit UI Action not working - Developer Community - Question - ServiceNow Community
Thanks.
Solved! Go to Solution.
- Labels:
-
Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 10:58 PM
Hi
You can use the g_form.submit to run the server side of ui action
g_form.submit(g_form.getActionName());
It will resolve the issue
OR
Rather than calling g_form.getActionName() we can directly pass the action name.
g_form.submit('action_name');
Here is an sample:
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'u_duplicate_incident',
label: getMessage('Duplicate Incident'),
mandatory: true,
reference: 'incident',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue()
}];
g_modal.showFields({
title: "Provide Duplicate Incident",
fields: fields,
size: 'sm'
}).then(function(fieldValues) {
g_form.setValue('close_code', 'Duplicate Incident');
g_form.setValue('close_notes', 'This is a duplicate Incident');
g_form.setValue('short_description', "Duplicate Incident -" + g_form.getValue('short_description'));
g_form.setValue('u_duplicate_incident', fieldValues.updatedFields[0].value);
g_form.submit('validate_check_duplicate');
});
}
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 10:58 PM
Hi
You can use the g_form.submit to run the server side of ui action
g_form.submit(g_form.getActionName());
It will resolve the issue
OR
Rather than calling g_form.getActionName() we can directly pass the action name.
g_form.submit('action_name');
Here is an sample:
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'u_duplicate_incident',
label: getMessage('Duplicate Incident'),
mandatory: true,
reference: 'incident',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue()
}];
g_modal.showFields({
title: "Provide Duplicate Incident",
fields: fields,
size: 'sm'
}).then(function(fieldValues) {
g_form.setValue('close_code', 'Duplicate Incident');
g_form.setValue('close_notes', 'This is a duplicate Incident');
g_form.setValue('short_description', "Duplicate Incident -" + g_form.getValue('short_description'));
g_form.setValue('u_duplicate_incident', fieldValues.updatedFields[0].value);
g_form.submit('validate_check_duplicate');
});
}
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 11:24 PM