0

I am using recordViewForm (in API version 43) because I have to use lightning:outputField tags inside for its automated formatting and features like mailTo, tel:, map on address, etc. (and I am pulling in the fields to be displayed dynamically from Custom Metadata type so I can not hardcode the field names and its types). I am NOT implementing force:hasrecordId interface as this component is added only in Custom Lightning component.

When I pass the record Id to recordViewForm, I see following error. For testing, I displayed record id just before recordViewForm tag so I am sure recordId is NOT null.

enter image description here

Now if I use lightning Data Service to get recordId and pass it to recordViewForm, I do not see above error however, none of the fields are displayed. I am stuck here due to dynamic nature of the field list that I want to display. Otherwise I could have simply hardcoded the field names according to their types.

Anybody else facing this issue? OR any help is appreciated?

  • We may need to see your code. – gNerb May 10 '18 at 21:46
  • This is essentially a duplicate of at least two previous questions that I will link for you. If the linked questions do not answer your question, please let us know and we will re-open this for you. – sfdcfox May 10 '18 at 21:50
  • None of the above links help me. Kindly reopen. All I am trying to do is, use recordViewForm without implementing force:hasRecordId interface. It does not works. I suspect the reason could be that it works only with hasrecordid interface and on standard record page. – Aditya May 10 '18 at 23:29
  • Great, @sfdcfox is right. Found my answer in the post marked at the top. Resolved my problem using <aura:if> approach. Apparently, lightning tries to render recordViewForm even before it gets back recordId asynchronously from JS controller and thus throwing null Id error. – Aditya May 11 '18 at 14:21
  • @Aditya Always glad to help! – sfdcfox May 11 '18 at 14:44