I am looking to store and auth token in a custom field for each Salesforce users. I read this post and consider the custom field to be suitable for my needs to store an auth token. There are plenty of examples on the web on how to collect data from Salesforces using the LWC web applications. These guidelines work well for collecting Salesforce default content.

The Questions

How do I reference/get data from a custom field created in Salesforce using the LWC approach? I have created a custom text field and added one record, but I can't seem to be able to get that record.

What I have tried

Before getting a custom field I have been practicing getting built in fields. I'm using these docs as a guide to get data for a "Contact" record, but the return value is just the record Id that I passed in. I can get a whole record using this example. But I want to just get the value of a single field.

My LWC app.js looks like this.

import { LightningElement } from 'lwc';
import { getFieldValue } from 'lightning/uiRecordApi';

export default class App extends LightningElement {

    renderedCallback() {
        setTimeout(() => {

                const record = { id: '0030k00000nqVl8AAE' }; // Id for a contact's record
                const result = getFieldValue(record, 'Contact.Name');
                console.log(result) // Displays { id: '0030k00000nqVl8AAE' }
            } catch(e){
        }, 5000)

  • Hey Jason, I made a couple of quick edits just to clarify: Salesforce DX is a development tool-chain/workflow that you use to build Lightning Web Components (among other things). It's a web component you've got here.
    – David Reed
    Mar 27, 2019 at 11:33

1 Answer 1


It's just "Name". Use the dot notation if you want a parent record's field.

const result = getFieldValue(record, 'Name');

Also, you should be importing field tokens instead:

import CONTACT_NAME_FIELD from '@salesforce/schema/Contact.Name';

Which you can then use in your method:

const result = getFieldValue(record, CONTACT_NAME_FIELD);

This eliminates the possibility of using the wrong name, as it will be validated by the server as part of the compilation process.

  • How about the record object? Is mine configured correctly? Your answer makes sense, but I still only get this value as a result { id: '0030k00000nqVl8AAE'}. Thank you so much. :) Mar 27, 2019 at 6:46
  • @JasonAllshorn That's what the docs say. geFieldValue should return a String value.
    – sfdcfox
    Mar 27, 2019 at 6:50
  • 2
    It seems strange. Whatever I pass in as the first argument of getFieldValue() I get returned from the function call. For example if I pass in "Hippo" I get "Hippo" as the return value without any errors. My expectation is to get back data stored in a Salesforce field. Mar 27, 2019 at 7:13

You must log in to answer this question.

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