I have what I feel like ought to be a super simple Lightning Web Component. I am showing this on a Tab in a record page for a Case.

Complete JS:

import { LightningElement, api, wire, track } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import IS_CLOSED from '@salesforce/schema/Case.IsClosed';

export default class CaseCloseForm extends LightningElement {
    @api recordId;

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

    get isClosed() {
        return getFieldValue(this.record.data, IS_CLOSED);



Complete HTML:

        Record ID: {recordId}<br/>
        Is Closed {isClosed}<br/>

Complete Metadata:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <description>Lwc Close Case</description>
    <masterLabel>Lwc Close Case</masterLabel>

UI Output:

enter image description here

Note that "Is Closed" returns no information, true or false.

I know that @wire runs asynchronously so I tried updating my template:

<template  >
    <template if:true={record.data}>
        record.data is true
    <template if:false={record.data}>
        record.data is false

This returns record.data is false in the UI and does not change.

Is there anything special I need to do to get this to run on a record page in a tab? What am I missing? I'm sure it's something simple. Thanks in advance.


JavaScript is cAsE-sEnSiTiVe. In this case, you tried to specify a parameter called FIELDS to getRecord, but it should have been fields.

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

When you specify a field from a variable:

let x = 5;
let y = { x };

You end up with a property of the same name and the value from the variable:

// y = { x: 5 }

Since you're supposed to all-caps a constant variable (this is definitely a good practice), you can't use the shorthand notation for the property.

  • Thank you for the quick reply, this is helpful, but I am not entirely sure I follow. I changed the value in the line from fields: FIELDS to fields: fields and now I get an error: ` [fields is not defined]`. My original post followed the pattern as specified in this this prior post: salesforce.stackexchange.com/questions/305264/… - practically speaking what do I need to change? Jan 25 at 3:39
  • @BobHatcher it should be fields: FIELDS, as in my answer. You wrote {recordId:'$recordId', FIELDS }.
    – sfdcfox
    Jan 25 at 3:45
  • Thank you - the line now reads @wire(getRecord, fields: FIELDS), but the compiler is complaining ("LWC1503: Parsing error: The type cast expression is expected to be wrapped with parenthesis"). But I still feel like I'm missing something - in the link above, Mert Yalti does it exactly as I did in my original post and it is an accepted answer. Was my way wrong? Jan 25 at 15:28
  • @BobHatcher You're missing curly brackets now. Look at my code again.
    – sfdcfox
    Jan 25 at 15:39
  • I just changed it back to @wire(getRecord, { recordId: '$recordId', fields: FIELDS }) as in my original post and it is now working, I wonder if it was a browser cache issue or something else wonky going on. Jan 25 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.