I want to auto populate Issue location, CCID, Simphony ID based on the opened for
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 12:27 AM
Hi,
I want to auto populate Issue location, CCID, Simphony ID based on the opened for.
But here Issue location and Simphony ID is coming from CCID table
sys_user (user) table screenshot:
CCID Table has Simphony ID and Issue location:
Thanks,
Sreenadh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 12:38 AM
Hi Sreenadh,
For cases like these that are more of double dot-walk I always fine Michale's article handy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 12:48 AM
Hi @kranthi2 You can do it in two ways
1st way:
1) Go to CCID Catalog variable, where you see Autopopulate section. Select Opened For as the dependent question and refence to CCID field.
2) Go to Issue location and Symphony ID Catalog variables, where you see Autopopulate section. Select CCID catalog variable as the dependent question and refence to Issue location and Symphony ID fields respectively.
2nd WAY:
Write an onchange client script for Opened for and set the values
Kindly mark the answer Correct and Helpful if it helps to resolve your issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 01:10 AM
Hi @kranthi2 here is the example , make sure field names and variable names are correct.
Script Include:
getRequestorDetails:function()
{
var userData = {};
var userCcid= '';
var SysID = this.getParameter('sysparm_id');//opened for sysid
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',SysID);
user.query();
if(user.next())
{
userCcid = user.getValue('ccid');//ccid field from user table
var cid = new GlideRecord('tableName'); // ccid table
cid.addQuery('ccid',userCcid);
cid.query();
if(cid.next())
{
userData.cid = user.getValue('u_uid');
userData.address = cid.getValue('address');
userData.id = cid.getValue('symphony_id');
}
}
var answer = JSON.stringify(userData);
return answer;
},
CLient Script:
client script onchange on opened For variable
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setValue('variablename', '');// to clear value when variable changes
return;
}
var si = new GlideAjax('Script Include Name');
si.addParam('sysparm_name', 'getRequestorDetails');// scriptinclude function name
si.addParam('sysparm_sysid', newValue); // opened for value
si.getXMLAnswer(parseResponse);
function parseResponse(answer) {
var response = JSON.parse(answer);
alert(JSON.Stringify(response,nulln4)); // check response from Script include
g_form.setValue('variableName', response.cid);
g_form.setValue('variableName', response.address);
g_form.setValue('variableName', response.id);
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 06:05 AM
Hello @kranthi2 ,
You can achieve this by setting auto populate field as well as with one OnChange Client script and script include, please refer the code below and let me know how it works for you.
Script Include (Name: "AutoPopulateScript"):
var AutoPopulateScript = Class.create();
AutoPopulateScript.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRequestorDetails: function() {
var userData = {};
var userCcid = '';
var SysID = this.getParameter('sysparm_sysid'); // opened for sysid
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', SysID);
user.query();
if (user.next()) {
userCcid = user.getValue('ccid'); // ccid field from user table
var cid = new GlideRecord('ccid_table'); // ccid table
cid.addQuery('ccid', userCcid);
cid.query();
if (cid.next()) {
userData.cid = user.getValue('u_uid');
userData.address = cid.getValue('address');
userData.id = cid.getValue('symphony_id');
}
}
return JSON.stringify(userData);
},
type: 'AutoPopulateScript'
});
Client Script (Type: onChange):
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var si = new GlideAjax('AutoPopulateScript');
si.addParam('sysparm_name', 'getRequestorDetails');
si.addParam('sysparm_sysid', newValue);
si.getXMLAnswer(parseResponse);
function parseResponse(answer) {
var response = JSON.parse(answer);
g_form.setValue('issue_location', response.address); // Replace 'issue_location' with your actual field name
g_form.setValue('ccid_field', response.cid); // Replace 'ccid_field' with your actual field name
g_form.setValue('simphony_id', response.id); // Replace 'simphony_id' with your actual field name
}
}
Please let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket