Issue with Script Include - Unhandled exception in GlideAjax

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 06:21 PM
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
-----------------------------------------------------------------
My onChange client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 06:40 PM
Hi @Community Alums ,
Can you try this below script & check
Script Include:
var FindAssetAssignedTo = Class.create();
FindAssetAssignedTo.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();
if (getAsgnTo.next()) {
var data = getAsgnTo.assigned_to.toString();
return data;
}
},
type: 'FindAssetAssignedTo'
});
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");
g_form.setValue('assigned_to' , answer);
}}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 06:45 PM
Hi @Community Alums
Can you try replacing,
var data = json.encode(object);
with
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 08:06 PM
Hi @Community Alums
Let's try this cool feature without single line of code. => Auto-populate
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 03:52 AM
Excellent, I knew about this for regular variables, but missed that it is an option with MRVS.
😀