- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:20 PM
Hello Experts!!
I am trying to fetch location from sys_user table to incident table in a custom field using getRefernce, but it is showing sys_id of the location.
Can anyone help ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:40 PM
If you're using getReference() to fetch the location from the sys_user table to the incident table in a custom field, it's expected that you're seeing the sys_id of the location. This is because getRefernce() retrieves the reference field value, which is typically the sys_id of the referenced record.
var locationSysId = current.location.toString(); // Assuming 'location' is the reference field name
// Fetch the location record
var locationRecord = new GlideRecord('sys_user');
if (locationRecord.get(locationSysId)) {
// Populate the location name in the custom field
current.custom_location_field = locationRecord.getValue('location'); // Assuming 'custom_location_field' is the custom field name
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:40 PM
If you're using getReference() to fetch the location from the sys_user table to the incident table in a custom field, it's expected that you're seeing the sys_id of the location. This is because getRefernce() retrieves the reference field value, which is typically the sys_id of the referenced record.
var locationSysId = current.location.toString(); // Assuming 'location' is the reference field name
// Fetch the location record
var locationRecord = new GlideRecord('sys_user');
if (locationRecord.get(locationSysId)) {
// Populate the location name in the custom field
current.custom_location_field = locationRecord.getValue('location'); // Assuming 'custom_location_field' is the custom field name
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 12:10 AM
Hi @Prerna_T ,
I recommend utilizing GlideAjax instead of Reference Qualifier for fetching location from sys_user to incident table's custom field due to an issue where the custom field displays sys_id instead of the actual location.
GlideAjax offers a cleaner and more customizable solution for asynchronous server-side JavaScript execution from the client side.
Steps:
- Create a Script Include to fetch location from sys_user.
- Develop a client-side script using GlideAjax to call the Script Include function.
This approach grants more control over data fetching and display, potentially resolving the sys_id display issue.
Please mark this response as helpful if your question has been answered correctly.