Skip to main content
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:

render can not set property undefined

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';

}

}

​​​​​​​
2 Antworten
  1. 3. Okt. 2019, 12:42

    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.

0/9000