- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:49 AM
Hello Folks,
i have Incident table i have create fields u_business_unit reference to business_unit table and u_deep which is reference to customer table
in customer table i have create 3 fields one is department (refe to cmn_department) and BU (ref to business_unit)
thats how its look like now
in incident i want whenever i select BU and when i reference to u_deep its should show all records where BU is HR , but right now its showing single records
Here is my refer qualifier on u_deep: javascript: new showdeparment().getdepartment(current.u_business_unit);
Script include
Can anyone help me where its getting wrong i really wanted to know
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:55 AM
@Aarushi1991 If you are getting logged all the records correctly and Ref qualifier is correctly configure , then I think issue is that is is referring to the same object again. You need to make it string where you are adding those sys ids. See the changes I think is the root cause it is not returning all the records:
var deparemt= new GlideRecord("u_customer_table");
deparemt.addQuery('u_bu',bussinessUnit);
deparemt.query();
while(deparemt.next()){
deparmentlist.push(deparemt.sys_id); //make it deparmentlist.push(deparemt.sys_id.toString())
gs.info("deparment"+deparmentlist);
}
return 'sys_idIN'+deparmentlist;
},
type: 'showdeparment'
};
Changing dept sys id as deparemt.sys_id.toString() will help resolve the issue.
Mark my response as helpful if it helped resolve your doubt.
Thank you,
Mahesh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:10 AM
@Aarushi1991 There is a concept called pass by value and pass by reference. Following line
deparmentlist.push(deparemt.sys_id);
pushes the reference (which is a memory address) of object deparemt.sys_id in array. With each array iteration the memory address for object deparemt.sys_id is overridden and finally with last iteration it is overriden by the memory address of the last object. To avoid this issue, either use .toString() or getValue() to extract the value and add it into the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:55 AM
@Aarushi1991 If you are getting logged all the records correctly and Ref qualifier is correctly configure , then I think issue is that is is referring to the same object again. You need to make it string where you are adding those sys ids. See the changes I think is the root cause it is not returning all the records:
var deparemt= new GlideRecord("u_customer_table");
deparemt.addQuery('u_bu',bussinessUnit);
deparemt.query();
while(deparemt.next()){
deparmentlist.push(deparemt.sys_id); //make it deparmentlist.push(deparemt.sys_id.toString())
gs.info("deparment"+deparmentlist);
}
return 'sys_idIN'+deparmentlist;
},
type: 'showdeparment'
};
Changing dept sys id as deparemt.sys_id.toString() will help resolve the issue.
Mark my response as helpful if it helped resolve your doubt.
Thank you,
Mahesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:04 AM
Thanks @maheshkhatal i want to understand this statement "I think issue is that is is referring to the same object again"
**toString is used to convert obj into string,also in log i am getting sys_id which is string value
can you help me understanding it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:10 AM
@Aarushi1991 There is a concept called pass by value and pass by reference. Following line
deparmentlist.push(deparemt.sys_id);
pushes the reference (which is a memory address) of object deparemt.sys_id in array. With each array iteration the memory address for object deparemt.sys_id is overridden and finally with last iteration it is overriden by the memory address of the last object. To avoid this issue, either use .toString() or getValue() to extract the value and add it into the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:26 AM
Thanks @Sandeep Rajput Something new i have learn today , i really appreciate your Explanation