I have a lightning-record-edit-form in a LWC. I started getting the QUERY_TOO_COMPLICATED error when loading the form. I have little to no control over the object so I can't simplify it.

My question is, can I limit the which fields are pulled into the form somehow to try and simplify the query?

My thinking is that it is trying to load all the data from the object even through I'm only using a small subset of those fields. I've tried taking everything out of the form and I'm still getting the error.

I've considered trying a lightning-record-form, but the client wants a lot of the fields to have different labels than what the fields actually have and I'm not sure if you can handle that in a record-form.

I can't really show a lot of the code due to business rules but this is all it is:

    <lightning-record-edit-form record-id={objectId} object-api-name="Custom_Object__c"> 

The custom object is huge and even when I don't have any fields in the form, like above, I still get the error.

  • Can you show us the code you currently have written in your LWC Nov 21, 2019 at 17:25
  • How many custom fields do you have on that custom Object? You are definitely hitting the 20k character limit. You may have to load your record via Custom Apex method and only querying the fields you need to work with. Nov 21, 2019 at 17:57
  • It's around 400 custom fields with way too many over complicated formulas (not my design). I think loading the record via Custom Apex is exactly what I want, but I'm not sure how to do that. Do you have an example or know where I can find one?
    – aaron
    Nov 21, 2019 at 18:09

2 Answers 2


I actually spoke too soon, you can actually achieve this without Apex. Here is an example from Salesforce's documentation https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_wire_adapters_record

import { LightningElement, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import OWNER_NAME_FIELD from '@salesforce/schema/Account.Owner.Name';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';
import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';

export default class Example extends LightningElement {
    @wire(getRecord, { recordId: '001456789012345678', fields: [NAME_FIELD, INDUSTRY_FIELD], optionalFields: [PHONE_FIELD, OWNER_NAME_FIELD] })

     get name() {
        return getFieldValue(this.account.data, NAME_FIELD);

    get phone() {
        return getFieldValue(this.account.data, PHONE_FIELD);

    get industry(){
        return getFieldValue(this.account.data, INDUSTRY_FIELD);

    get owner() {
        return getFieldValue(this.account.data, OWNER_NAME_FIELD);

<template if:true={account.data}>
    <div class="slds-m-around_medium">
        <p>Account Name: {name}</p>
        <p>Industry: {industry}</p>
        <p>Phone: {phone}</p>
        <p>Owner: {owner}</p>
  • can you add relevant code to your answer?
    – RedDevil
    Nov 21, 2019 at 19:46
  • @RedDevil just included the code from the Salesforce documentation link I provided Nov 21, 2019 at 19:48

@Bryan, thanks, you got me most of the way there. From your link, I went further and found the updateRecord method which allows me to get the data for the page load and allow it to be updated.

It's located here: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_update_record

It's going to be a lot of manual re-work. I wish the lightning-record-edit-form would only load the data needed for the page, but I think this is the only way that I can do what I need. Thanks for your help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .