I am creating a LWC that handles data from an external object. I have access to the recordId through @api recordId;, but I need to get the externalId from this object as well.

Currently, I have call to an APEX class that simply returns the ExternalId of that record.

public with sharing class EnterpriseCaseHandler {
     public static String getCaseRecordID(ID currentRecordId){
        return [SELECT ExternalId FROM EntCase__x WHERE id= :currentRecordId LIMIT 1].ExternalId; 

While this works, I am wondering if there is a way to eliminate this call and get the field value of ExternalId directly from the record.

I am trying to follow this documentation: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_get_field_value

Is there support for external objects? I may have the schema incorrect, just not sure how to determine what it should be.

Here is my code:

import { LightningElement, track, api, wire } from "lwc";
import { getRecord, getFieldValue } from "lightning/uiRecordApi";
import EXTERNAL_ID from "@salesforce/schema/EntCase__x.ExternalId"; // External Object

const fieldValues = [EXTERNAL_ID];

export default class ChatterData extends LightningElement {

   * Get the field values for this external case record
  @wire(getRecord, { recordId: "$recordId", fieldValues })

   * Get the externalId for this case record
  get externalId() {
    return getFieldValue(this.entCase.data, EXTERNAL_ID);

  renderedCallback() {
    let external = getFieldValue(this.entCase.data, EXTERNAL_ID);
    console.log(external) // returns {}
    console.log(this.entCase.data) // returns {} 
    console.log(this.entCase) // returns {}

  • I don't have external objects in my org to test against, but I wouldn't be too optimistic about being able to use the UI API here (see docs: developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/…). The syntax mostly looks all right, except it does occur to me that renderedCallback() might execute before your wired record is populated. What happens if you put <p>{externalId}</p> somewhere in the template? If you don't see it then, I would go back to Apex. Dec 9, 2019 at 17:22
  • 2
    @MatthewSouther - Bummer, I tried that as well using the getter and it didn't display. I added an error callback to my @wire and got a response of aura_prod.map.js:41912 {"ok":false,"status":500,"statusText":"Internal Server Error","body":{"errorCode":"INVALID_FIELD","message":"Entity name for the provided record didn't match required field EntCase__c.ExternalId","stack":"Error: Entity name for the provided record didn't match required field EntCase__c.ExternalId\n . Looks like it is trying to use EntCase__c vs EntCase__x. Doesn't appear to support external objects from what I can tell
    – SBB
    Dec 9, 2019 at 17:30

1 Answer 1


I've seen that even though we import the field from the external object path .../externalObject__x.customfield__c the objectApiName of the imported field will have the custom object suffix ( __c ) instead of the external object suffix( __x ).

I've managed this to work by manually defining the structure of the field and making sure the objectApiName has an external suffix instead of a custom one.

   //Defined outside the class
    const FIELDS = [
        fieldApiName: 'myExternalField__c',

    @wire(getRecord, { recordId: "$recordId", fields: FIELDS})

Hope this works!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .