Having problem with onLoad client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 05:58 AM
Hi everyone,
I am working on onLoad Client script and script include . I am facing problem that I am not getting back response from script include . I have placed alert(res) , and it is giving null value.
Script Include:
var DisplayModelName = Class.create();
DisplayModelName.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getName: function() {
var url_sysID = this.getParameter('sysparm_id');
gs.info("sys id of url " +url_sysID);
var table = new GlideRecordSecure('x_care3_carear_fsm_instruct_experience');
table.addQuery('sys_id', url_sysID);
table.query();
if (table.next()) {
var name = table.getValue('instruct_model_name');
gs.info("name of model" +name);
}
return name;
},
type: 'DisplayModelName'
});
.
Client Script :
function onLoad() {
//Type appropriate comment here, and begin script below
var doc;
var iframe = top.document.getElementById('gsft_main'); //main iframe
var listIframe = iframe ? iframe.contentWindow.document.querySelector('[name=gsft_list_form_pane]') : null; //split view iframe
//listIframe is null if iframe is null (when open record outside of frame, ie. not within nav_to) OR can not be determined by the selector above (for when the record is opened in regular form view, no split view)
if (listIframe == null) {
doc = iframe ? iframe.contentWindow.document : top.document;
} else
doc = listIframe.contentWindow.document; //listIframe exists when record is opened in split view, set doc to listIframe.contentWindow.document
var element = doc.getElementById('wm_task.x_care3_carear_fsm_instruct_experience_value.instruct_model_url_link');
alert(g_form.getValue('x_care3_carear_fsm_instruct_experience_value'));
if (element)
element = g_form.getValue('x_care3_carear_fsm_instruct_experience_value'); //set text of URL
var ga = new GlideAjax('x_care3_carear_fsm.DisplayModelName');
ga.addParam('sysparm_name', 'getName');
ga.addParam('sysparm_id', element);
ga.getXMLAnswer(modelName);
function modelName(response) {
var res = response.reponseXML.documentElement.getAttribute('answer');
alert(res);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2022 04:10 AM
Hi Virendra,
What is the field type of 'instruct_model_name' is this a String field?
Ethan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 09:48 PM
Hi
Have you tried using just getXML() instead of getXMLAnswer()?
Regards,
Vamsi S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2022 11:23 PM
Hi
Yes . I have tried that also.