cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Dropdown: How to update the Fill on selection?

I have a Dropdown control in a Gallery Template that has different colours based on the percentComplete record value. To do that I set the Fill property:

Fill = Switch(percentComplete, 0, Silver, 50, LightSkyBlue, 100, LightGreen)

All good.

However, when I change the selection in the Dropdown, eg to change the task from "In Progress" to "Completed" (ie percent completed from 50 to 100) the item colour does not change.

Is it possible to "repaint" the control, or rerun the Fill function somehow, so the colour changes in line with the selected item?

 

Thanks,

Murray

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

OK. Got it working. This is the setup:

The DropDown control is called "TaskStatus" and is in the Gallery Template whose records are Planner Task records which have an integer percentComplete field.

As I understand it (and I am new so this might be incorrect) in PowerApps DropDowns do not have a Value and DisplayText pair that other languages have. I am allowing filtering on the Task Status (percentComplete) via a Combo box so to dry up my code, in the onStart of my app I create a global collection like so:

ClearCollect(collTaskStatus, { p: 0, nn: "Not started" }, { p: 50, nn: "In Progress" }, { p: 100, nn: "Completed" });

then on the TaskStatus dropdown in the Gallery Template the properties are:

Items = collTaskStatus // My global collection as above
Val... = nn // The text value property in the collection
// My Fill which changes colour depending on the value of ThisItem.percentComplete
Fill = Switch(ThisItem.percentComplete, 0, Silver, 50, LightSkyBlue, 100, LightGreen)

onChange = 
// Update the server using the UpdateTaskV2 function which expects percentComplete to be a string:
Planner.UpdateTaskV2(
    id,
    {percentComplete: TaskStatus.SelectedText.nn}
);

// Patch the record in the collection so percentComplete gets set. The Fill "listener" hears that change and updates the Fill colour according to the Switch function as above
Patch(
    varServerTasks,  // My collection of Task records previously collected
    First(
        Filter(
            varServerTasks,
            id = ThisItem.id  // id is the task id
        )
    ),
    {percentComplete: TaskStatus.SelectedText.p}
);

 

Thanks! 😁

 

View solution in original post

2 REPLIES 2
v-siky-msft
Community Support
Community Support

Hi @Anonymous ,

 

What is "percentComplete"? Variable?

Do you mean that drop down items are related to percent complete? in another word, what is the relationship between percentComplete record value and drop down items

 

The reason that fill doesn't update is that the percentComplete doesn't change when you select the dropdown item.

So you need to set OnChange property of dropdown to set the percentComplete record value when you select the corresponding items.

 

If(Dropdown1.Selected.Value="In Progress",Set(percentComplete,50),Dropdown1.Selected.Value="Completed",Set(percentComplete,100))

 

Note: The formula might not be Dropdown1.Selected.Value,  it depends on the items and field properties of dropdown.

Hope this helps.

Best regards,

Sik

If my post is helpful for you, please click on “Accept as Solution” to help other members find it more quickly.

 

Anonymous
Not applicable

OK. Got it working. This is the setup:

The DropDown control is called "TaskStatus" and is in the Gallery Template whose records are Planner Task records which have an integer percentComplete field.

As I understand it (and I am new so this might be incorrect) in PowerApps DropDowns do not have a Value and DisplayText pair that other languages have. I am allowing filtering on the Task Status (percentComplete) via a Combo box so to dry up my code, in the onStart of my app I create a global collection like so:

ClearCollect(collTaskStatus, { p: 0, nn: "Not started" }, { p: 50, nn: "In Progress" }, { p: 100, nn: "Completed" });

then on the TaskStatus dropdown in the Gallery Template the properties are:

Items = collTaskStatus // My global collection as above
Val... = nn // The text value property in the collection
// My Fill which changes colour depending on the value of ThisItem.percentComplete
Fill = Switch(ThisItem.percentComplete, 0, Silver, 50, LightSkyBlue, 100, LightGreen)

onChange = 
// Update the server using the UpdateTaskV2 function which expects percentComplete to be a string:
Planner.UpdateTaskV2(
    id,
    {percentComplete: TaskStatus.SelectedText.nn}
);

// Patch the record in the collection so percentComplete gets set. The Fill "listener" hears that change and updates the Fill colour according to the Switch function as above
Patch(
    varServerTasks,  // My collection of Task records previously collected
    First(
        Filter(
            varServerTasks,
            id = ThisItem.id  // id is the task id
        )
    ),
    {percentComplete: TaskStatus.SelectedText.p}
);

 

Thanks! 😁

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,590)