
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 05:26 AM
Hi,
The task is to get sysID of the record and put into another variable. I am getting the output as null via addInfoMessage.
Script Include
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax("onChangeStChSysIDClass");
ga.addParam("sysparm_name", "onChangeStChSysIDFunction");
ga.addParam("sysid_key", newValue);
ga.getXML(callBackFunction);
function callBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage("answer is " + answer);
g_form.setValue("standard_change_template_sys_id", answer);
}
}
Script Include
var onChangeStChSysIDClass = Class.create();
onChangeStChSysIDClass.prototype = Object.extendsObject(AbstractAjaxProcessor, {
onChangeStChSysIDFunction:function(){
var keyClientScript = this.getParameter("sysid_key");
var userId_DB = "";
var userGR = new GlideRecord("std_change_template");
userGR.addQuery("sys_id", keyClientScript);
userGR.query();
if (userGR.next()) {
userId_DB = userGR.getValue("sys_id");
return userId_DB;
}
},
type: 'onChangeStChSysIDClass'
});
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 06:59 AM
yes please write that code in onchange client script.
g_form.getValue('standard_change_template')
as this is reference field it returns sysid by default.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 06:24 AM
Hi @Community Alums
you can directly map it instead of using script include
g_form.setValue("standard_change_template_sys_id", g_form.getValue('standard_change_template'));
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 06:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 06:59 AM
yes please write that code in onchange client script.
g_form.getValue('standard_change_template')
as this is reference field it returns sysid by default.
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 07:04 AM
Hi @priyasunku
I just used this
var sysID = g_form.getValue('standard_change_template').toString();
g_form.setValue("standard_change_template_sys_id",sysID );
Regards
Suman P.