cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mikkiel
Frequent Visitor

Patching dropdown value from collection

Hi,

 

I'm having a problem with the value of my dropdown not being passed correctly to my collection.

 

I have a gallery that gets its items from my 'Template' table. Each 'template' contains some values that need to be passed to a new 'Checklist Item' along with user input. One of these inputs is a dropdown. 

 

Mikkiel_0-1594907152067.png

 

I'm not allowed to actually create any records unless everything is filled in, so my save button should collect everything from the gallery and then use patch to create new records.

 

This is the code that runs when I press save.

 

Patch(
    Inspectierapporten,
    Defaults(Inspectierapporten),
    {
        Project: SelectedProject,
        Categorie: SelectedCat
    }
);
Clear(ItemsToSubmit);
ForAll(
    NewReportItems.AllItems,
    Collect(
        ItemsToSubmit,
        {
            Rapport: Last(Inspectierapporten),
            Categorie: SelectedCat,
            Naam: ItemName.Text,
            Inspectieresultaat: [@ConclusionDropdown],
            Template: SelectedCat.Template
        }
    )
);
ForAll(
    ItemsToSubmit,
    Patch(
        'Inspectie onderdelen',
        Defaults('Inspectie onderdelen'),
        {
            Rapport: Rapport,
            Categorie: Categorie,
            Inspectieresultaat: Inspectieresultaat,
            Naam: Naam
        }
    )
)

 

 

Now this works for what I need, only the dropdown value is never passed. I'm sure its got something to do with how I save the dropdown in the collection, but I can't seem to figure it out on my own.

 

I've got two problems with the dropdown:

 

1). I have a custom option set, but cannot seem to populate the dropdown with the set unless I use this code as ThisItem does not refer to the entity that actually contains the option set field.

 

[
    [@Conclusie].'Niet geïnspecteerd',
    [@Conclusie].Goedgekeurd,
    [@Conclusie].Gebrek,
    [@Conclusie].Afgekeurd,
    [@Conclusie].'Niet van toepassing',
    [@Conclusie].'In backlog'
]

 

 

2). Passing the value to the collection and then successfully patching it to the CDS, which may be a direct result of 1)

 

 

I'm sure my code might make some people cringe when they read it, but I'm only just starting with powerapps and CDS in general and I'm very aware it's not elegant at all.

 

Thanks in advance,

 

M-

1 ACCEPTED SOLUTION

Accepted Solutions
Mikkiel
Frequent Visitor

Absolutely bloody typical I'd struggle a day, make a post only to figure it out shortly after.

 

Turns out I was an idiot.

 

I needed to pass the ConclusionDropdown.Selected instead of the entire dropdown, and then patch the InspectieResultaatCol.Value. In hindsight, probably should've figured that out sooner.

View solution in original post

1 REPLY 1
Mikkiel
Frequent Visitor

Absolutely bloody typical I'd struggle a day, make a post only to figure it out shortly after.

 

Turns out I was an idiot.

 

I needed to pass the ConclusionDropdown.Selected instead of the entire dropdown, and then patch the InspectieResultaatCol.Value. In hindsight, probably should've figured that out sooner.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,478)