Getting Error Match not found, reset to original and not able to save the records,, Kindly help
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 01:58 AM
Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
alert("Client Script started");
var street = g_form.getValue('street'); // will return sys_id
if (!street) {
alert("No street selected. Please select a valid street.");
return;
}
alert("SysId " + street);
var ga = new GlideAjax('CityAutoPopulate');
ga.addParam('sysparm_name', 'PopulateCity');
ga.addParam('sysparm_value', street); // Whatever street we select on... its pass on the server side
ga.getXML(getResponse);
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var test = answer.split(',');
g_form.setValue('city', test[0]);
g_form.setValue('postal_code', test[1]);
alert("City set to: " + answer);
}
//Type appropriate comment here, and begin script below
}
AND
Script Include
var CityAutoPopulate = Class.create();
CityAutoPopulate.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
PopulateCity: function() {
var sysIdOfStreet = this.getParameter('sysparm_value'); // Will return sys_id
var gr = new GlideRecord('cmn_location');
gr.addQuery('sys_id', sysIdOfStreet);
gr.query();
if (gr.next()) {
return gr.city + ',' + gr.zip;
} else {
return ''; // Return empty string if no match is found
}
},
type: 'CityAutoPopulate'
});
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 08:27 AM
Hi @AnjuG
I think you can use JSON.stringify() while returning the values from script include and everything else seems fine.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 09:50 AM
@AnjuG The code looks fine, did you check if there is a street associated with the sys_id you are passing from the client side?