getReference value

Prerna_T
Tera Contributor

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 ?

1 ACCEPTED SOLUTION

Maddysunil
Kilo Sage

@Prerna_T 

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

View solution in original post

6 REPLIES 6

Maddysunil
Kilo Sage

@Prerna_T 

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

Dipen Wadhwana
Giga Guru

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:

  1. Create a Script Include to fetch location from sys_user.
  2. 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.