How to Extract a User from a ReferenceId Field

    Assume you would like to send the email address of the incident.caller to the other side. incident.caller is a reference and looks like

    [display_value:Taylor Vreeland, link:https://dev78307.service-now.com/api/now/v2/table/sys_user/46bac3d6a9fe1981005f299d979b8869]
    To extract the user you can use the getTableByLink function
    if(!(incident.caller_id instanceof String)){
      replica.callerMail = nodeHelper.getTableByLink(incident.caller_id?.link)?.email
    }

    As a side note that the user table has much more fields

     Expand source
    [
    default_perspective:
     first_name:Fred
     city:
     name:Fred Luddy
     mobile_phone:
     sys_mod_count:10
     introduction:
     source:
     internal_integration_user:false
     avatar:
     location:[...]
     latitude:
     photo:
     zip:
     email:fred.luddy@example.com
     sys_updated_on:2020-04-03 20:40:35
     sys_id:5137153cc611227c000bbd1bd8cd2005
     time_sheet_policy:
     state:
     vip:false
     calendar_integration:1
     cost_center:[...]
     agent_status:
     notification:2
     user_password:...
     home_phone:
     preferred_language:en
     country:
     sys_created_by:GUEST
     building:
     sys_created_on:2004-05-02 00:00:00
     longitude:
     sys_domain:[...]
     geolocation_tracked:false
     on_schedule:
     company:[...]
     department:[...]
     last_position_update:
     last_name:Luddy
     locked_out:false
     roles:admin, itil
     middle_name:
     manager:
     schedule:
     ldap_server:
     last_login:
     street:
     title:Programmer
     date_format:
     employee_number:
     web_service_access_only:false
     sys_domain_path:/
     time_format:
     sys_class_name:sys_user
     sys_updated_by:developer.program@snc
     password_needs_reset:false
     user_name:fred.luddy
     failed_attempts:
     time_zone:US/Pacific
     enable_multifactor_authn:false
     phone:
     last_login_time:
     gender:Male
     sys_tags:
     active:true].