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
Microsoft
Microsoft

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (982)