5

I wrote a lightning web component that includes a lightning-record-edit-form component. We are using PersonAccounts here and there are 2 RecordTypes on PersonAccount as well.

The Type__c field is a picklist, with Record-type dependent values. However, the values shown are always, 100% of the time, the ones belonging to the default RT for the user. Not even hardcoding the other RT Id in the record-type-id property makes them appear.

Does anybody have any clue as to what's going on?

PS: both the markup and the JS code are heavily abbreviated, I only left what felt relevant.

Markup (Only relevant part shown)

<template for:each={allPeople} for:item="person">
  <div key={person.email}>
    <lightning-record-edit-form object-api-name="Account" record-id={person.id}
                            onsuccess={handleUpdateAccountSuccess}
                            record-type-id={person.recordTypeId}>

    <lightning-input-field field-name="Name">
    </lightning-input-field>
    <lightning-input-field field-name="PersonEmail" disabled>
    </lightning-input-field>
    <lightning-input-field field-name="Type__c">
    </lightning-input-field>
    <lightning-input-field field-name="LinkedInURL__pc">
    </lightning-input-field>
    <lightning-input-field field-name="RecordTypeId" disabled
                           value={person.recordTypeId}>
    </lightning-input-field>

    <div class="slds-m-top_medium">
        <lightning-button variant="brand" type="submit" name="save"
                          label="Update Account">
        </lightning-button>
    </div>
    </lightning-record-edit-form>
  </div>
</template>

Controller (only relevant parts shown)

@api
get people() {
    return this._people;

}

set people(value) {
    this._people = value;

    let aggregate = [];

    aggregate.push(this._people.from);

    for (let i = 0; i < this._people.to.length; i++) {
        aggregate.push(this._people.to[i]);
    }

    for (let i = 0; i < this._people.cc.length; i++) {
        aggregate.push(this._people.cc[i]);
    }

    this.allPeople = aggregate;
    this.refreshPeople();
}
  • 2
    I hard-coded record-type-id in markup for 2 person account record types and could see picklist value changing, There might be something else messing up. Probably person.recordTypeId is blank? or its should be RecordTypeId? – Pranay Jaiswal Jul 16 '19 at 9:51
  • Hey there, the field that you see at the bottom of the form is displaying properly. So it’s not a casing issue. Did you try inside of a “repeat”? – Sebastian Kessel Jul 16 '19 at 14:40
  • Have you set a default record type in Personal Settings for the user ? Can you try removing it. – Anshul Agrawal Jul 17 '19 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.