0

Is there anyway in LWC to create an array that has a type of my custom object? In aura, we could do it with "<aura:attribute name="groupstructures" type="Group_Structure__c[]"/>" I'm trying to create an array that contains all the record information of my custom object. I know that I can display one record as my objectd type using lightning-record-edit-form but I'm trying to display a list of records just like I would one record in lighting-record-edit-form. I've been working on this for a while from different angles and just can't seem to get there. Thanks!!!!

1
  • can you please explain a little bit more, what do you want this array for?
    – ytiq
    Jan 29, 2021 at 19:02

1 Answer 1

0

An array in LWC is just an array, and objects in LWC are just plain objects. You don't need to specify the type, you just create records. If you need this for sending to Apex, just initialize the data as a normal object with an attributes property:

{ "attributes": { "type": "Group_Structure__c" }, "name": "Whatever", ... }

It's considered a bad practice, though, to use multiple lightning-record-edit-form elements at once, as this causes a lot of bandwidth usage and can considerably slow your application down. You might want to consider lightning-datatable instead, or use your own templates.

P.S. It's hard to tell what your intent is; consider asking the question you want to ask directly. You can read more about the X-Y Problem.

2
  • I'm trying to create a clone process where the user selects a number (1 to 9) and then uses a row action to copy that record x number of times but can also edit the values before saving. Thanks for responding!!
    – Frank
    Jan 29, 2021 at 19:22
  • 1
    @Frank Yes, sounds like you want either a lightning-datatable or a custom input form.
    – sfdcfox
    Jan 29, 2021 at 19:59

You must log in to answer this question.

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