I have a custom object that has fields that sometimes has data and sometimes doesn't. I'm trying to loop through those fields in my component, but having big problems because the field doesn't show up on the objects where it is blank.

IE Object 1 has field, object 2 doesn't all are in a array returned to component.

So I figure maybe I can just test to see if the field is missing and add in something in javascript, but it's not even letting me do that. For example if field's name is Tier__c, and object variable name is prod

I've tried

try { if (prod.Tier__C) {} catch (e) { prod.Tier__c = '' }

if ($A.util.isEmpty(prod.Tier__C)

if (prod.hasOwnProperty(Tier__C)

But in all cases I get the error "Error during init [Cannot read property 'apply' of undefined]"

any ideas?


  • It's __c, not __C. JavaScript is case sensitive. Make sure that you're respecting case sensitivity. And none of those constructs should ordinarily be necessary. I have a feeling you've misidentified the cause of the issue.
    – sfdcfox
    Dec 3, 2016 at 0:05
  • Maybe, but I put "if (prod.Tier__c == NULL) {prod.Tier__c = 'Tier 1';} " in my apex class and the error went away....
    – Krone
    Dec 3, 2016 at 5:40
  • You were right, I was wrong, I found my error, I was missing a "V" somewhere
    – Krone
    Dec 3, 2016 at 15:59


You must log in to answer this question.

Browse other questions tagged .