The CreatorCon Call for Content is officially open! Get started here.

Issue with Script Include - Unhandled exception in GlideAjax

Community Alums
Not applicable

I think I am pretty close with this, but getting error Unhandled exception in GlideAjax

I am creating MRVS, when asset is selected I need to populate the assigned_to for the asset.

 

My script includes

var FindAssetAssignedTo = Class.create();
FindAssetAssignedToHardware.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSupportGrp: function()
{
var asgnTo=this.getParameter('syspam_assigned_to_sysid');
var getAsgnTo=new GlideRecord('alm_hardware');
getAsgnTo.addQuery('sys_id',asgnTo);
getAsgnTo.query();
 
while(getAsgnTo.next()) {
var json = new JSON();
 
var object = {
"assignedto" : getAsgnTo.getValue("assigned_to"),
 
};
 
var data = json.encode(object);
 
return data;
}
},
 
type: 'FindAssetAssignedToHardware'
});

 

-----------------------------------------------------------------

My onChange client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var ga= new GlideAjax('FindAssetAssignedToHardware');
ga.addParam('sysparm_name','getSupportGrp');
ga.addParam('syspam_assigned_to_sysid',newValue);
 
ga.getXML(FindAssetAssignedToHardwareParse);
 
function FindAssetAssignedToHardwareParse(response) {
 
 
var answer = response.responseXML.documentElement.getAttribute("answer");
 
//var returneddata = answer.evalJSON(true);
var returneddata = JSON.parse(answer);
 
g_form.setValue('assigned_to' , returneddata.assignedto);
}}
-----------------------------------------------------
Any ideas?
7 REPLIES 7

Hi @Lon Landry4 ,

 

If our responses helped you could you please mark the responses as "Solution Accepted" as it will help other users to find the correct answer.

 

Thanks,

Danish

 

Lon Landry4
Mega Sage

Hi Danish,
The answer that best solved my requirement was TAI Vu.

Also, the mark as correct button seems to have been removed as an option...

Hi @Lon Landry4 ,

 

No worries you can mark his solution as accepted. In the end it will benefit other users when they receive. I think u raised the question with diff ID maybe that's y not getting an option to accept. Happy learning 🙂

 

Thanks,

Danish