I want to destroy a from the workspace
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi All,
I have a requirement when user type in the worknotes and a form open ups using the UIpage.
The below called in the onchange cliet script.
g_modal.showFrame({
g_modal.showFrame({
title: 'My Popup',
url: '/workspace.do',
size: 'md'
});
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div style="padding: 15px;">
<h3>Workspace Modal Dialog Form</h3>
<!-- Dummy form field input example -->
<div class="form-group" style="margin-bottom: 15px;">
<label for="user_notes">Add Processing Notes:</label>
<textarea id="user_notes" class="form-control" rows="4"></textarea>
</div>
<!-- Execution Action Footer Buttons -->
<div style="text-align: right; margin-top: 20px;">
<button type="button" class="btn btn-default" onclick="dismissModal()" style="margin-right: 10px;">
Cancel
</button>
<button type="button" class="btn btn-primary" onclick="submitAndClose()">
Submit Data
</button>
</div>
</div>
</j:jelly>
client script in UI page:
client script in UI page:
function submitAndClose() {
if (window.top.g_modal) {
window.top.g_modal.destroy();
} else if (GlideDialogWindow.get()) {
GlideDialogWindow.get().destroy();
}
}
I after entering the required information when I click on the submit it should close the form, right now its not working as expected.
Thanks,
I after entering the required information when I click on the submit it should close the form, right now its not working as expected.
Thanks,
Sai.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
update your workspace client script like this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || !newValue) {
return;
}
g_modal.showFrame({
title: 'My Popup',
url: 'your_ui_page_name.do',
size: 'md',
callback: function(confirmed, data) {
if (confirmed) {
if (data && data.user_notes) {
g_form.setValue('work_notes', data.user_notes);
}
}
}
});
}
UI page
<?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:requires name="iframeHelper.jsdbx" />
<div style="padding: 15px;">
<h3>Workspace Modal Dialog Form</h3>
<div class="form-group" style="margin-bottom: 15px;">
<label for="user_notes">Add Processing Notes:</label>
<textarea id="user_notes" class="form-control" rows="4"></textarea>
</div>
<div style="text-align: right; margin-top: 20px;">
<button type="button" class="btn btn-default" onclick="dismissModal()" style="margin-right: 10px;">
Cancel
</button>
<button type="button" class="btn btn-primary" onclick="submitAndClose()">
Submit Data
</button>
</div>
</div>
</j:jelly>
Client Script
$j(document).ready(function () {
if (typeof iframeHelper !== 'undefined') {
iframeHelper.hideCloseButton();
iframeHelper.autoResize();
}
});
function dismissModal() {
if (typeof iframeHelper !== 'undefined') {
iframeHelper.cancel();
}
}
function submitAndClose() {
var notes = $j('#user_notes').val();
if (typeof iframeHelper !== 'undefined') {
iframeHelper.confirm({
user_notes: notes
});
}
}
refer below
Workspace Modals – Working with UI Pages
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader