<template for:each={openCases.data} for:item="cs">
 <span key={cs.Id}> {cs.Title__c} on {caseName} </span>


    @wire(getCaseList, { Id: '$caseId' }) openCases;
    get caseName(){
     //above log returns the data
     /*{"data":[{"Id":"b6m3C000000LGQuQAO","Title__c":"Unable to Login","Account__r":{"Name":"","Id":"j6o3C0000004N67QAE"}}]}*/

          // returns Cannot read property 'Title__c' of undefined


Can some help me on why the property values are being returned undefined although I'm able to see that property has been defined?


It seems like it is returning an array with a length of 1 for data. So you would have to do:

  • ah, I totally didn't see that I was looping through. I see that there is for:index="index" on for each, how do I pass the index to JS. Thanks!
    – cartman
    Nov 20 '19 at 21:55
  • Not sure I understand, are your trying to construct the case name in JS? Can you just not call it directly in your span tag? Nov 20 '19 at 22:02
  • Yes,my question was how to pass index on to component. I have too many if conditions and I believe it would easier returning the values at JS level.
    – cartman
    Nov 21 '19 at 17:16
  • So there is a for:index attribute, however, I don't know if there is a way to pass an iteration of a for:each to a JS method (i.e. {jsFunc(ind)}) Nov 21 '19 at 17:23

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.