- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 09:22 AM
I have an SI to populate a JSON string in a drop-down. However, I am unsure where and how to code the input for the variable string.
SI
var Test = Class.create();
Test.prototype = Object.extendsObject(AbstractAjaxProcessor, {
CourseUtils: function()
{
try {
var r = new sn_ws.RESTMessageV2('Banner Courses', 'get');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
return responseBody;
}
catch(ex) {
var message = ex.getMessage();
return "";
}
},
type: 'Test'
});
CS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 09:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 09:55 AM
Looks like your Client Script didn't post. What is an example of the expected responseBody you are passing to the client?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 07:39 AM
{"TERM_DESC":"Fall 2024","SUBJ_CODE":"SOCI","CRSE_NUMB":"245","SEQ_NUMB":"50P","INSTRUCTOR":" "},
Also, here is my CS:
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('Test');
ga.addParam('sysparm_name','CourseUtils');
ga.getXML(CourseUtilsOutput);
}
function CourseUtilsOutput(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var objJSON = JSON.parse(answer);
for(var loop = 0 ; loop < objJSON.courses.length;loop++)
{
/*alert(objJSON.courses[loop].Name);
g_form.addOption('course_information',objJSON.courses[loop].Value,objJSON.courses[loop].Name);*/
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 08:54 AM - edited 09-20-2024 08:56 AM
@appstorm ok in for loop
sample code
for (var i = 0; i < objJSON.courses.length; i++) {
var choice=objJSON.courses[i];
g_form.addOption('course_information', choice.SUBJ_CODE + ' ' + choice.CRSE_NUMB+' '+ choice.SEQ_NUMB, choice.TERM_DESC);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 06:49 AM
Thank you for this - exactly what I was looking for. I'm still getting a Unhandled exception in GlideAjax console error. I'll have to work on decoding that and see where the problem(s) exist.