Timeline for Use LWC @wire(getRecord) when recordId is not always present
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 9, 2019 at 9:00 | history | tweeted | twitter.com/StackSalesforce/status/1159751183990497280 | ||
Aug 8, 2019 at 5:52 | vote | accept | Robert Sösemann | ||
Aug 7, 2019 at 16:32 | comment | added | Brett Nelson | I think the issue might be where the fields of the record that you get from Salesforce is are accessed. Are you checking for null/undefined at each level of your record object? I think I talk about it briefly here wipdeveloper.com/lwc-getting-data-with-the-wire-service | |
Aug 7, 2019 at 14:51 | comment | added | Brett Nelson | @RobertSösemann are you decorating a property or a method? | |
Aug 7, 2019 at 13:01 | comment | added | Robert Sösemann | is if(this.recordId){ @wire(getRecord, { recordId: "$recordId", fields: this.fields}) } really valid JS?! | |
Aug 7, 2019 at 12:30 | history | edited | Robert Sösemann | CC BY-SA 4.0 |
added 5 characters in body
|
Aug 7, 2019 at 12:05 | answer | added | salesforce-sas | timeline score: 9 | |
Aug 7, 2019 at 12:02 | comment | added | sanket kumar | Yes a simple if(this.recordId){ @wire(getRecord, { recordId: "$recordId", fields: this.fields}) } would work. I would like to know more about your html file. When call fails, what kind of issue you have o screen? | |
Aug 7, 2019 at 11:56 | comment | added | Lance Shi | In that case, you can simply handle undefined in your apex I suppose? | |
Aug 7, 2019 at 11:46 | comment | added | Robert Sösemann | @salesforce-sas It is part of a generic component which can go on any page. I just need a way to not make parts of the code fail in such cases | |
Aug 7, 2019 at 11:45 | comment | added | Robert Sösemann | When a LWC is on a record Page a @api recordId; is populated with the current record id. It stays undefined if the same LWC is on a Home Page. | |
Aug 7, 2019 at 11:45 | comment | added | salesforce-sas | Why is GetRecord needed on home page? | |
Aug 7, 2019 at 11:44 | comment | added | Lance Shi | What do you want the recordId to be in this case? | |
Aug 7, 2019 at 11:14 | history | asked | Robert Sösemann | CC BY-SA 4.0 |