function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan A FoxJonathan A Fox 

render can not set property undefined

Hi all,

My LWC is a button which changes the status to closed and is only visible/'not grey' when the status is anything but 'closed.

I place the LWC on the Lightning record page and get presented with the error:

User-added image

Here is my HTML:
 
<template>
    <div></div>
            <template if:true={isSelectClosed}>
                <lightning-button class="slds-button slds-button_destructive" onclick={handleClick}>Close Open Ended Status</lightning-button>
            </template>
</template>

and here is my JS:
import { LightningElement, api, wire } from 'lwc';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import npe03__Open_Ended_Status__c from '@salesforce/schema/npe03__Recurring_Donation__c';

export default class OpenEndedCloseButton extends LightningElement {
    @api recordId;
    @api selectVal;
    @wire(getPicklistValues, { recordId: '$recordId', fields: npe03__Open_Ended_Status__c  })

    handleClick(){
        this.recordId.npe03__Open_Ended_Status__c = 'Closed';
    }
    get isSelectedClosed(){
        return this.recordId.selectVal === 'Closed';
    }

}

​​​​​​​
Best Answer chosen by Jonathan A Fox
jprichterjprichter

That error is coming from what is line 11 in your code snippet. Your code is trying to find a property called npe03__Open_Ended_Status__c on this.recordId, but it's not an object, it's just the record Id which is a string. 

 You might want to consider using lightning-record-edit-form (https://developer.salesforce.com/docs/component-library/bundle/lightning-record-edit-form/documentation) to give you access to the full record and not just the Id.

All Answers

jprichterjprichter

That error is coming from what is line 11 in your code snippet. Your code is trying to find a property called npe03__Open_Ended_Status__c on this.recordId, but it's not an object, it's just the record Id which is a string. 

 You might want to consider using lightning-record-edit-form (https://developer.salesforce.com/docs/component-library/bundle/lightning-record-edit-form/documentation) to give you access to the full record and not just the Id.

This was selected as the best answer
Jonathan A FoxJonathan A Fox
@jpritcher thanks, I just want the button to be a nice quick method thats all. So how would you suggest chaning this?