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

How to Control Combobox and Dropdown in a New Row in a Gallery

Hello!

 

I have an embedded canvas app set up to mimic an excel sheet where users can add new rows and edit existing ones. It pretty much functions as needed with two exceptions, and I'm not sure how to tackle them.

 

1. I need the Milestone Status dropdown when a new row is added to default to Active. I did figured out how to get SOMETHING to show up by setting the AllowEmptySelection to false, but whatever shows up seems to be based off of whatever status is the first row.

 

2. I need the Associated Project combobox when a new row is added to show up as whatever project the user is currently in. In the example below, I have navigated to the canvas app via the project Test 2.  It is correct for the existing rows to be whatever they are, in this case Test 1, but when a new item is added, it should look to the context and grab that project, in this case Test 2. Currently it defaults to nothing. 

 

 

sjd889_0-1671140782750.png

 

 

Any help is appreciated!

 

5 REPLIES 5
BCBuizer
Super User
Super User

Hi @sjd889 ,

 

For both of your questions you can use the Default property of the controls:

 

1. 

Coalesce(ThisItem.'Milestone Status',"Active")

 2.

Coalesce(ThisItem.'Associated Project', XYZ)

You'll have to replace XYZ with a reference to the value/record for the selected project.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Thanks for the response! Just tried the first one really quick and Coalesce(ThisItem.'Milestone Status', "Active") leads to an error saying it was expecting an OptionSetValue but received a Text value instead. How do I correct that?

Okay! Was able to get it by changing it to Coalesce(Text(ThisItem.'Milestone Status'), "Active").

 

Still not clear on what to add to the formula for the second one. Currently in DefaultSelectedItems I have:

 

LookUp(
colProject,
Project = ThisItem.'Associated Project'.Project

 

So I imagine

Coalesce(

LookUp(
colProject,
Project = ThisItem.'Associated Project'.Project), ????)

 

But not sure what to put there because how does it know which project the user is currently in? This needs to be dynamic and not just me telling it a project name the way I am telling it a status in the other scenario.

 

Okay! I figured out that I needed to enable the ModelDrivenFormIntegration to get the context. I was able to get the contextual project name with the code ModelDrivenFormIntegration.Item.'Project Name' which is awesome, and I am putting it into the coalesce with the lookup statement I know works for pulling the list of project options and it's cranky because the lookup statement is a record value and the modeldrivenformintegration piece is text.

 

Any ideas on how to adjust this to make the comparision valid?

 

Coalesce(LookUp(
colProject,
Project = ThisItem.'Associated Project'.Project),
ModelDrivenFormIntegration.Item.'Project Name')

BCBuizer
Super User
Super User

Hi @sjd889 ,

 

I can imagine it will look something like the below:

 

Coalesce(
    ThisItem.'Associated Project',
    LookUp(
        colProject,
        Project = ModelDrivenFormIntegration.Item.'Project Name'
    )
)

 

Both arguments should return a record.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,323)