Ui page pop up close auto matically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 12:02 AM
Hi All,
I need to show a custom popup when a user click on publish button on knowledge article. I have created a UI Page and added code to the "publish" ui action. The popup appears onclick as expected, however, it closes automatically and almost immediately. Is there code that I'm missing to make the UI Page wait for input before disappearing?
ui action script "
function onPublishActionClicked() {
var dialog = new GlideDialogWindow("test");
dialog.setTitle("Please provide comments on what was updated or changed in this article"); //Set the dialog title
dialog.render(); //Open the dialog
if (g_form.getTableName() == "kb_knowledge_block")
gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
else {
var checkGuestAccess = new GlideAjax("KBAjax");
checkGuestAccess.addParam("sysparm_type", "checkGuestUserHasAccess");
checkGuestAccess.addParam("sysparm_id", g_form.getUniqueValue());
checkGuestAccess.getXML(function(response) {
var answer = '';
if (response && response.responseXML && response.responseXML.documentElement)
answer = response.responseXML.documentElement.getAttribute("answer") + '' == 'true' ? true : false;
if (answer)
renderModal();
else
gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
});
}
}
function renderModal() {
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
dialog = new dialogClass('confirm_publish');
dialog.setTitle('Confirmation');
dialog.setWidth(450);
dialog.render();
}
if (typeof window == 'undefined') {
publish();
}
function closeDialogAndPublish() {
dialog.destroy();
gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
}
function publish() {
new global.KnowledgeUIAction().publish(current);
//current.setAbortAction(current);
}
<?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>
<table>
<tr>
<td style="width:60%">
<textarea name ="work_notes" id="work_notes" cols="20" rows="20" maxlength="10"></textarea>
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="return continueCancel()"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
function continueOK() {
var work_notes = gel('work_notes').value;
work_notes =trim(work_notes);
if(work_notes==''){
alert('please enter comments');
return false;
}
GlideDialogWindow.get().destroy();
g_form.setValue('u_pr',work_notes);
}
function continueCancel(){
GlideDialogWindow.get().destroy();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 04:48 AM
Hi @v-paulp
Did you select client checkbox for the UI Action?
if yes, which function was mentioned in Onclick field?
I am assuming that onPublishActionClicked function was mentioned in Onclick field. In this function, you should not run other code if you want to render UI page as GlideDialogWindow.render() will not wait for the execution it gives back the control immediately to execute the subsequent code if defined. so, you need to handle the logic of publishing also in the UI page itself. Modify the UI action like below:
function onPublishActionClicked() {
var dialog = new GlideDialogWindow("test");
dialog.setTitle("Please provide comments on what was updated or changed in this article"); //Set the dialog title
dialog.render(); //Open the dialog
}
function renderModal() {
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
dialog = new dialogClass('confirm_publish');
dialog.setTitle('Confirmation');
dialog.setWidth(450);
dialog.render();
}
if (typeof window == 'undefined') {
publish();
}
function closeDialogAndPublish() {
dialog.destroy();
gsftSubmit(null, g_form.getFormElement(), 'publish_knowledge');
}
function publish() {
new global.KnowledgeUIAction().publish(current);
//current.setAbortAction(current);
}