Call Glideajax from UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 05:47 AM - edited 01-08-2025 05:57 AM
Hi Experts,
I'm working on a scoped application and I have built the UI action and Script include
Client:true
onclick:request_Sign()
On click of button I'm getting the info message Method satisfied only
function request_Sign() {
var method = g_form.getValue('consumer_signature_method');
var sysID = g_form.getUniqueValue();
// Check if the method is either 'email' or 'sms'
if (method === 'email' || method === 'sms') {
g_form.addInfoMessage('Method satisfied');
// Create a GlideAjax object and call the Script Include
var ga = new GlideAjax('x_comms_man_0.ConsentAjaxUtils');
ga.addParam('sysparm_name', 'handleSignatureMethod');
ga.addParam('sysparm_method', method); // Pass the method (email/sms)
ga.addParam('sysparm_record', sysID); // Pass the sys_id of the record
// Handle the response from GlideAjax
ga.getXMLAnswer(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage('Answer received: ' + answer); // Log the answer received
// Check if the response is success and show an appropriate message
if (answer == 'success' && method == 'email') {
gs.eventQueue("call the event to sent notofication");
g_form.addInfoMessage('Email sent successfully.');
} else if (answer == 'success' && method == 'sms') {
g_form.addInfoMessage('SMS sent successfully.');
}
});
}
}
Script include:
client callable:true
var ConsentAjaxUtils = Class.create();
ConsentAjaxUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
handleSignatureMethod: function() {
gs.info("Script Include is triggered", 'QHConsentAjaxUtils');
var method = this.getParameter('sysparm_method');
var sysID = this.getParameter('sysparm_record');
gs.info("Received parameters - method: " + method + ", sysID: " + sysID, 'QHConsentAjaxUtils');
return 'success';
},
type: 'ConsentAjaxUtils'
});
In the script include I'm getting both the info messages
only thing is in the UI Action the return value is not receiving and info messages based on return value
Your responses is much appreciated
Thankyou.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 06:27 AM
Have you tried using getXML rather than getXMLAnswer? It looks like you are parsing out your answer variable, which is consistent with the getXML call.