0

I have a SObject with multiple display layouts. Now, I want a way to display a particular layout in my lightning-record-form with different lightning-input-field.

I don't wanna attach all the fields in my form one-by-one as it will consume lot of time and efforts.

I want a way to pick my selected fields from my custom created Object Layouts.

Suggest me a way to ensure this. The image shows different Layouts for same object and I want to display in lightning-record-form on the basis of selection of layout.

0

You could use field sets in combination with lightning-record-form, which are specifically designed for this use case. There is no feasible way to query a layout and extracting the fields on the layout.

<lightning-record-form
    record-id="001XXXXXXXXXXXXXXX"
    object-api-name="Account"
    layout-type="Full"
    mode="view"
    fields={getFieldsToDisplay}>
</lightning-record-form>

You can then implement the getFieldsToDisplay function in your js controller either hard coded (return an array) or dynamically by quering field sets.

0

It is possible to get the fields in certain section of a layout of sObject - through metadata API in apex. There is MetadataService apex class in which you will get all these classes already implemented. You can download the required classes from https://github.com/financialforcedev/apex-mdapi.

You can use classes Layout, LayoutSection, LayoutItem etc to get the fields.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.