Make a Field Mandatory when user clicks on Retire Button for Knowledge Articles in Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @21121A3359 ,
In your UI Action Add this script :
function onClick() {
var mandatoryField = g_form.getValue('u_retire_reason');
if (!mandatoryField) {
g_form.showFieldMsg('u_retire_reason', 'Please provide a reason before retiring.', 'error');
return false; // Prevent Retire action
}
return true;
}
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@yashkamde
No not working can you please share output if you got it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
can you plz share the code where you use this and what's error getting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @21121A3359
Try this - updating Retire UI Action:
Navigate to System Definition > UI Actions.
Search for the global Retire UI action that applies to the Knowledge Article [kb_knowledge] table.
Ensure Client is checked.
In the Onclick field, enter runRetireAction()
function runRetireAction() {
var retireField = g_form.getValue('your_field_name');//Replace 'your_field_name' with your actual field
if (!retireField) {
g_form.showFieldMsg('your_field_name', 'Please provide a reason before retiring.', 'error');
return false;
}
g_form.setMandatory('your_field_name', true);
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update');
}
if (typeof window == 'undefined') {
retireKnowledgeArticle();
}
function retireKnowledgeArticle() {
current.workflow_state = 'retired';
current.update();
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti