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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (100,194)