cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Btoth
New Member

Create/Update nested collection dynamically

Have a collection (vmList) which stores virtual machines and their relevand key:value pairs, like Name, CPU, RAM, etc. One of which is a collection (VM_DisksList) where I want to store an ID and size of each disk for each VM. The VM_DisksList collection should be crated dynamically base on a dropdown (HwCfg_DD_VmPlusDisks) list, where the user specify how my disk should have each VM. And on the next step (next screen) users could specify the size of the disks.

 

My last try is the following. The code is on the "On Change" field of the mentioned dropdown (HwCfg_DD_VmPlusDisks) element:

 

 

Clear(vmDisks);
ForAll(
    Sequence(HwCfg_DD_VmPlusDisks.Selected.Value + 1),
    Collect(
        vmDisks,
        {
            Disk_ID: Value,
            Disk_Size: If(
                Value = 1, //Refers to the 1st element of the VM_DisksList, which is allways the OS disk.
                Value(HwCfg_TxtI_VmOsDiskSize.Text), //If it's the OS disk, the size is coming from the specified textInput.
                10 //else give it a default value: 10 (GB).
            )
        }
    )
);
Patch(vmList, LookUp(vmList, Row_ID = ThisItem.Row_ID), {VM_DisksList: vmDisks})

 

With the above code, I got warning about  "VM_DisksList" does not match the expected type 'record'. found type 'table'

 

1 REPLY 1
RusselThomas
Community Champion
Community Champion

Hi @Btoth ,

I was trawling through some older posts and found this - have you managed to solve it yet?

If not - you said VM_DisksList is a collection - but by the code it appears that it's a column in a collection that contains a collection (vmDisks), is that correct? 

Kind regards,

RT

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,989)