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
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,307)