Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
64 views1 page

GlideAjax Example 1 Word

This document summarizes client-side and server-side code for retrieving location data. The client-side code uses a GlideAjax call to call the getCampus method on the server. It passes the building ID and calls an updateCampus callback on response. The server-side code defines a getCampus method that gets the parent location (campus) of the given building ID. It returns the campus sys_id and name encoded as JSON. If no building is found, it returns null.

Uploaded by

Saran Ravikumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views1 page

GlideAjax Example 1 Word

This document summarizes client-side and server-side code for retrieving location data. The client-side code uses a GlideAjax call to call the getCampus method on the server. It passes the building ID and calls an updateCampus callback on response. The server-side code defines a getCampus method that gets the parent location (campus) of the given building ID. It returns the campus sys_id and name encoded as JSON. If no building is found, it returns null.

Uploaded by

Saran Ravikumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Client Side Server Side

function onChange(control, oldValue, newValue, isLoading) { var asu_GetLocationData = Class.create();


if (isLoading || newValue == '') { asu_GetLocationData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
return; getCampus: function () {
} var buildingid = this.getParameter('sysparm_buildingid');

var ga = new GlideAjax('asu_GetLocationData'); var loc = new GlideRecord('cmn_location');


ga.addParam('sysparm_name', 'getCampus'); if (loc.get(buildingid)) {
ga.addParam('sysparm_buildingid', g_form.getValue("u_building")); var campus = new GlideRecord('cmn_location');
ga.getXML(updateCampus); if (campus.get(loc.parent)){
} var json = new JSON();

var results = {
function updateCampus(response) { "sys_id": campus.getValue("sys_id"),
var answer = response.responseXML.documentElement.getAttribute("answer"); "name": campus.getValue("name")
var clearvalue; // Stays Undefined };
if (answer) {
var returneddata = answer.evalJSON(true);
g_form.setValue("campus", returneddata.sys_id, returneddata.name); return json.encode(results);
} else { }
g_form.setValue("campus", clearvalue);
}
} } else {

return null;
}

});

You might also like