Populate two fields based configuration item "group owned by vendor"and "Application ID"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 04:46 AM
The above two fields from the : cmdb_ci_appl.u_business_application.support_group.u_owner , cmdb_ci_appl.u_application_id
client script:
var ciInfo = g_form.getValue("select_the_application_business_application_the_audit_request_applies_to");
//alert(ciInfo);
var sI = new GlideAjax("populateCIFields");
sI.addParam("sysparm_name", getData);
sI.addParam("sysparm_data", ciInfo);
sI.getXMLAnswer(populateCIGroup);
function populateCIGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("values are" + answer);
var da = JSON.parse(answer);
alert(da);
var a = g_form.setValue("group_owned_by_vendor", da.groupOwned);
var b = g_form.setValue("application_id", da.applicationID);
Script Include:
var populateCIFields = Class.create();
populateCIFields.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getData: function() {
var sysid = this.getParameter("sysparm_data");
gs.addInfoMessage(sysid);
var obj = {};
var ciApplication = new GlideRecord("cmdb_ci_appl");
ciApplication.addQuery("sys_id", sysid);
ciApplication.query();
if (ciApplication.next()) {
obj.groupOwned = ciApplication.u_business_application.support_group.u_owner.toString();
obj.applicationID = ciApplication.u_application_id.getDisplayValue();
}
gs.addInfoMessage(obj.groupOwned);
return JSON.stringify(obj);
},
type: 'populateCIFields'
});
Some one help me to achieve this and thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 08:37 AM
I see one issue in the below line. getData should be within quotes. Please check and let me know if this fixes your issue:
sI.addParam("sysparm_name", "getData");
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 02:14 AM
HI @jai16 ,
Did you try the suggestion in your old script? I see that you added gs.addInfoMessage in few places. Let me know which ones are printing and which one is not.
Also let me know the response for alert("values are" + answer); command?
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 11:42 AM - edited 09-17-2023 11:43 AM
Hello @jai16 ,
Kindly Create an Onchange Client script on 'select_the_application_business_application_the_audit_request_applies_to' field and try to utilize the following code.
Client Script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//var ciInfo = g_form.getValue("select_the_application_business_application_the_audit_request_applies_to");
//alert(ciInfo);
var sI = new GlideAjax("populateCIFields");
sI.addParam("sysparm_name", 'getData');
sI.addParam("sysparm_data", newValue);
sI.getXML(populateCIGroup);
function populateCIGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
try {
answer = answer.evalJSON();
} catch (e) {
answer = JSON.parse(answer);
}
//alert(answer);
g_form.setValue("group_owned_by_vendor", answer.groupOwned);
g_form.setValue("application_id", answer.applicationID);
}
//Type appropriate comment here, and begin script below
}
Script Include :
var populateCIFields = Class.create();
populateCIFields.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getData: function() {
var sysid = this.getParameter("sysparm_data");
gs.addInfoMessage(sysid);
var obj = {};
var ciApplication = new GlideRecord("cmdb_ci_appl");
ciApplication.addQuery("sys_id", sysid);
ciApplication.query();
if (ciApplication.next()) {
obj.groupOwned = ciApplication.u_business_application.support_group.u_owner.toString();
obj.applicationID = ciApplication.u_application_id.getDisplayValue();
}
var json = new global.JSON();
data = json.encode(obj);
gs.addInfoMessage(data.groupOwned)
return data;
},
type: 'populateCIFields'
});
If my answer solves your issue please mark it as Helpful 👍 and Accepted✔️ based on impact.
Thanks & Regards,
Sunny R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 01:45 AM
Not working