Corrent ActionName is not populating for Close Complete in Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi All,
When I am trying to execute onSubmit Client script using actionName="closeComplete" Condition, but everytime actionName is coming as "sysverb_ws_save" , and client script is not running.
I am trying to execute glidemodal pop up when actionName='closeComplete'.
Workspace = HR Agent Workspace
Any solution will be highly appreciated.
Here is my onSubmit Client Script code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi jitusingh,
This is expected behavior in Workspace
1. Root cause
- In Workspace,
g_form.getActionName()
Always returnssysverb_ws_save
It does NOT return UI Action names like closeComplete
2. Why your script is not working
- Workspace uses Declarative Actions, not classic UI Actions
- So your condition:
action_name == 'closeComplete'Will never be true
3. Recommended fix
Don’t use
getActionName()in WorkspaceInstead:
Move logic to Workspace Action (Declarative Action)
- Configure:
- Action = Close Complete
- Add client script / modal logic there
4. Alternative
If you must use Client Script:
- Check field/state change instead of action name
if (g_form.getValue('state') == 'closed_complete') {
// trigger modal
} - Configure:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
if (g_form.getValue('state') == 'closed_complete') {
// trigger modal
}
if I use this , the form will be saved first and then popup will appear but if i cancel the popup the form will be already saved to Close complete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
This is a known behavior, you will not get that action name
since you want your code to run for close complete button better to add the workspace code in Workspace client script and use g_modal there
Something like this
function onClick(g_form) {
var reasons = [{
displayValue: "Cancellation Requested",
value: "Cancellation Requested"
}, {
displayValue: "Incorrect Case Record Type",
value: "Incorrect Case Record Type"
}, {
displayValue: "Missing Information",
value: "Missing Information"
}, {
displayValue: "Redirected",
value: "Redirected"
}, {
displayValue: "Resolution Provided",
value: "Resolution Provided"
}, {
displayValue: "Knowledge – based Resolution: Article Fully Resolved Case",
value: "Knowledge – based Resolution: Article Fully Resolved Case"
}, {
displayValue: "Knowledge – based Resolution: Article Used with Agent Support",
value: "Knowledge – based Resolution: Article Used with Agent Support"
}, {
displayValue: "Knowledge – based Resolution: Article Inaccurate or Incomplete",
value: "Knowledge – based Resolution: Article Inaccurate or Incomplete"
}, {
displayValue: "Knowledge – based Resolution: No Article Available",
value: "Knowledge – based Resolution: No Article Available"
}, {
displayValue: "Service Processing - Transaction",
value: "Service Processing - Transaction"
}, {
displayValue: "Duplicate Case",
value: "Duplicate Case"
}, {
displayValue: "Resolution Provided by Vendor",
value: "Resolution Provided by Vendor"
}];
var fields = [{
type: 'choice',
name: 'reason',
label: getMessage('Reason'),
value: reasons[0].value,
choices: reasons,
mandatory: true
}, {
type: 'textarea',
name: 'work_notes',
label: getMessage('Close notes'),
mandatory: true
}];
g_modal.showFields({
title: getMessage('Closed Reason'),
instruction: getMessage('Provide a reason for closing the case as complete.'),
fields: fields,
size: 'md'
}).then(function(result) {
var updatedFields = result.updatedFields || [];
var reason = updatedFields[0] ? updatedFields[0].value : '';
var workNotes = updatedFields[1] ? updatedFields[1].value : '';
var ga = new GlideAjax('sn_hr_core.ConnectMeHRUtils');
ga.addParam('sysparm_name', 'closedCaseAction');
ga.addParam('sysparm_obj_id', g_form.getUniqueValue());
ga.addParam('sysparm_table_name', g_form.getTableName());
ga.addParam('sysparm_work_note', workNotes);
ga.addParam('sysparm_suspend_reason', reason);
ga.getXMLAnswer(function() {
g_form.submit('closeComplete');
});
});
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have put the above code in Workspace client script inside Close Complete UI action , But the popup is not coming also the form is getting saved to close_complete.
This is not working.
