callback function from UI page always returning false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 01:09 AM
Hello All,
I have created a UI page which should open in workspace and on click of cancel button, I need clear all the field and close the current window.
I am using a on change client script for this
Here am getting false always when clicking on cancel and continue button?
How can I get get on click on cancel get false and continue button get true value so that I can do my validation?
g_modal.showFrame({
url: "sn_customerservice_s.do?sysparm_stacks=no&sysparm_workspace=" + true + "&sysparm_sys_id=" + g_form.getValue("u_installed_base_item"),
size: 'lg',
height: '56vh',
title: '',
callback: function(confirmed, data) {
alert(confirmed);
g_form.setValue("account","");
}
});
/* v
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:02 AM
I believe there is a difference when the modal gets invoked from client script and workspace client script which is present in UI action
What's your business requirement here?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:07 AM
hi,
On change of a field need to open a pop a message which will contain list of open incident case etc with cancel and continue button. On click of cancel button close the current window and on click on continue button stay on same page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:30 AM
then why to use UI page when you wish to simply show OK and Continue?
Why not use Confirm box and let user see OK and Cancel?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:06 AM
When I using below code to display list of records then the pop itself not appearing.
I am commenting the line till message,then popup is coming getting true and false too
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/* g_modal.showFrame({
url: "sn_customerservice_CasePopupMessage.do?sysparm_stack=no&sysparm_workspace=" + true + "&sysparm_sys_id=" + g_form.getValue("u_installed_base_item"),
size: 'lg',
height: '56vh',
title: '',
callback: function(confirmed, data) {
alert(confirmed);
g_form.setValue("account","");
}
});*/
var installedbaseitem = g_form.getValue("u_installed_base_item");
var ga = new GlideAjax('sn_customerservice.B2BCasePopupUtil');
ga.addParam('sysparm_name', 'getRelatedRecords'); // Method in the script include
ga.addParam('installBaseItem', installedbaseitem);
ga.getXMLAnswer(function(response) {
if (!response) {
alert("No data returned from the server.");
return;
}
// Parse the response
var result = JSON.parse(response);
alert(JSON.stringify(result));
if (!result || (!result.cases.length && !result.changes.length && !result.incidents.length)) {
alert("No open records found for the selected Installed Base Item.");
return;
}
var message = '<table style="width: 100%; border: 1px solid #ddd; border-collapse: collapse;">';
message += '<tr><th>Number</th><th>State</th><th>Category</th></tr>';
for (var i = 0; i < result.cases.length; i++) {
var c = result.cases[i];
var casenumber = "<a href='/sn_customerservice_.do?sys_id=" + c.sys_id + "'>" + c.number + "</a>";
var url = 'now/cwf/agent/record/sn_customerservice/' + c.sys_id; // Workspace URL
message += '<tr>';
message += '<td>' + casenumber + '</td>'; // Hyperlink
message += '<td>' + c.state + '</td>';
message += '<td>' + (c.category || 'N/A') + '</td>';
message += '</tr>';
}
for (var j = 0; j < result.changes.length; j++) {
var ch = result.changes[j];
var url2 = '/now/cwf/agent/record/change_request/' + ch.sys_id; // Workspace URL
message += '<tr>';
message += '<td><a href="' + url2 + '" target="_blank">' + ch.number + '</a></td>'; // Hyperlink
message += '<td>' + ch.state + '</td>';
message += '<td>' + (ch.category || 'N/A') + '</td>';
message += '</tr>';
}
for (var k = 0; k < result.incidents.length; k++) {
var inc = result.incidents[k];
var url3 = '/now/cwf/agent/record/incident/' + inc.sys_id; // Workspace URL
message += '<tr>';
message += '<td><a href="' + url2 + '" target="_blank">' + inc.number + '</a></td>'; // Hyperlink
message += '<td>' + inc.state + '</td>';
message += '<td>' + (inc.category || 'N/A') + '</td>';
message += '</tr>';
}
message += '</table>';
alert(message);
})();
g_modal.confirm(getMessage("Pricing Action"),
getMessage("Accept list price from default price list?"),
function(confirmed) {
alert(confirmed);
if (confirmed) {
onCompleteWorkspace();
} else {
onCancelWorkspace();
}
});
}
function onCompleteWorkspace() {
setTimeout(function() {
g_form.setValue("account", '');
}, 100);
}
function onCancelWorkspace() {
setTimeout(function() {
alert("hello");
}, 100);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:46 AM
what's your use case to show list of incidents?
the agents simply want to see the records?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader