+ Start a Discussion

lightning:recordViewForm doesn't like 18-char record ids in Spring '18


My lightning component started throwing an "invalid record id" error after the Spring '18 upgrade.  It turns out that I was passing an 18-char id in the recordId attribute of lightning:recordViewForm.  When I made that a 15-char id, the error went away. 

Isn't Salesforce supposed to accept both 18-char ids and 15-char ids?


- Randy
Raj VakatiRaj Vakati
 it is working... Check the Fileds and record types and objectApiName  are correct or not once.
<aura:component implements="lightning:actionOverride,force:hasRecordId,force:hasSObjectName">
    <lightning:recordViewForm recordId="0061N00000T5uBBQAZ" objectApiName="Opportunity">
        <div class="slds-box">
            <lightning:outputField fieldName="Name" />
            <lightning:outputField fieldName="Amount" />
            <lightning:outputField fieldName="CloseDate" />
            <lightning:outputField fieldName="Description" />
            <lightning:outputField fieldName="ExpectedRevenue" />
            <lightning:outputField fieldName="StageName" />
            <lightning:outputField fieldName="Probability" />
            <lightning:outputField fieldName="Type" />
            <lightning:outputField fieldName="CurrentGenerators__c" />
            <lightning:outputField fieldName="TrackingNumber__c" />

Thanks for that response.  If I hard-code the 18-char record id, it works for me as well.  But my code is looking up the record id like so:

                    <lightning:recordViewForm recordId="{!v.simpleRecord.Id}" objectApiName="Opportunity">
                        <lightning:outputField fieldName="Chart_of_Accounts__c" variant="label-hidden"/>

where the v.simpleRecord attribute is populated by force:recordData.  Now that you've convinced me that it's not to do with 15-char versus 18-char, I'm wondering if it's because the recordId attribute wants a string rather than an Id.  Because I'm in Classic, force:hasRecordId doesn't work so I can't get the freebie v.recordId.  If you agree about the Id versus String thing, do you know any way to convert inside the attribute assignment?  None of these attempts work:

  recordId="{!'' + v.simpleRecord.Id}"


- Randy