- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2018 01:46 PM
Hey Community,
I'm working on making a client script that forces a confirmation dialog box when a user tries to click the retire button in an article. The box pops up properly when selected, but when you click "OK" it re-routes directly back to the dialog box. It will only successfully retire the article after you hit "OK" once then click "Cancel" the second time. Below is the code I'm using in the client script. Any suggestions would be greatly appreciated!
function onSubmit() {
var action = g_form.getActionName();
if(action=="retire"){ //Retire button's action name
var answer = confirm('Are you sure you want to retire this article?');
if(answer == true){
gsftSubmit(null, g_form.getFormElement(), 'retire'); //Retire button's action name
}
else{
return false;
}
}
}
Solved! Go to Solution.
- Labels:
-
Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2018 03:17 PM
Hi Chazzer,
The below code works for me.
moveToRetire() ;
function retire(){ var answer=confirm("ARe you sure you want to retire this article");
if (!answer)
{
alert('This article was not retired');
}
else{
gsftSubmit(null, g_form.getFormElement(), 'retire'); // copy UI action name
}
}
function moveToRetire(){
if(new KBKnowledge().canRetire(current)){
if (current.kb_knowledge_base.kb_version == "3" && new KBWorkflow().startWorkflow(current, "retire_workflow")) {
if(current.workflow_state != 'retired'){
current.update();
}
gs.addInfoMessage(new KBKnowledge().getStateMessage(current.getValue("workflow_state")));
} else if (current.kb_knowledge_base.kb_version == "2") {
current.workflow_state = 'retired';
current.update();
gs.addInfoMessage(new KBKnowledge().getStateMessage(current.getValue("workflow_state")));
}
if(typeof RP !== 'undefined'){
if(RP.getParameterValue("sysparm_referring_url").indexOf('kb_view.do') >= 0){
gs.setRedirect("kb_view.do?sys_kb_id=" + current.sys_id);
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 06:24 AM
Thank you Supriya,
This script worked perfectly as intended!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2018 10:14 AM
Does this solution work for others folks as well? I get :
Uncaught ReferenceError: KBKnowledge is not defined at moveToRetire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 02:35 AM
Its working, but some of the article are going in "Pending Reirement" state instead of "Retired"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 07:09 AM
Do you have an approval process for retiring articles? Check the related approval records to see if one was created when trying to retire.