# lightning:recordForm - Error when layout contains recordTypeId

I have a component that contains lightning:recordForm like so:

<lightning:recordForm
recordId="001f200001Zg2uYAAR"
objectApiName="Account"
layoutType="Compact"
columns="3"
mode="edit" />


If the layout that is rendered contains "Account Record Type" the following error is displayed at the top of the form:

Field: RecordTypeId is not a valid lookup field.

Is this a known issue? I have not seen other reports of this.

• I observed this too. You may need to reach out to the Salesforce support. – Jayant Das Sep 25 '18 at 12:48
• Yes, had the same issue. Best to raise a case with Salesforce. – Ranga Sep 25 '18 at 13:51
• Does this org have Account Record Types defined? – Jeremy Nottingham Sep 25 '18 at 14:06
• Yes @JeremyNottingham, there are Account Record Types defined. – Homerlex Sep 25 '18 at 14:55

Edit @Homerlex I found a workaround if you find the proper record type Id in the init method of your component and save it to an attribute variable called recordTypeId and then update your lighting record form to this, it should remove the error

Component

<lightning:recordForm
aura:Id="createAcct"
recordId="001f200001Zg2uYAAR"
objectApiName="Account"
layoutType="Compact"
columns="3"
mode="edit"
onSubmit="{!c.handleSave}" />


Controller

handleSave : function(cmp, event, helper){
event.preventDefault(); // stop form submission
var eventFields = event.getParam("fields");
eventFields['RecordTypeId'] = cmp.get('v.recordTypeId');
cmp.find('createAcct').submit(eventFields);
}

• Thanks @CalvinOKeefe. I opened a case with support and they haven't given me an answer yet. – Homerlex Sep 26 '18 at 15:56
• let me know if they tell you something different if you ever hear back from them! – Calvin OKeefe Sep 26 '18 at 19:31

You just need to take the record type off of the page layout that you are using. You will spot getting the error.

• Thats not always possible from a requirements standpoint – Calvin OKeefe Oct 25 '18 at 19:07