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

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,803)