Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Combobox defaultselecteditems based on other combobox value

(0) ShareShare
ReportReport
Posted on by 92

Hi everyone,

 

I'm making some improvements to a timesheet app I've built and I've hit a dead-end with how to solve a problem I've come up against.

 

I'm adding a new field to my app called "Timesheet Type", which is a choice column through which the user can select one of the following options:

 

  • Standard
  • Holiday
  • Sick

 

If they select "Standard", all of the fields are displayed for them to fill out, e.g. start time, finish time, worksite name, etc.

 

timesheet standard.PNG

 

If they select "Holiday" or "Sick" then I am wanting to hide most fields (apart from Date and Type) and fill in preset data for all of these hidden fields.

 

As an example, if the user selects "Holiday" it would set Start Time Hour to "07", Start Time Minute to "30", Work Site to "Holiday" etc. and hide these fields from them.

 

This works fine for "Work Site", which is a text column that I add the word "Holiday" to. What I have an issue with is getting it to select the choice in the combobox and save it. Here is my code for the Start Time Hour data card, defaultselecteditems property:

 

 

 

If(DataCardValue5.Selected.Value = [@'Timesheet Type'].Holiday, ["07"],
If(DataCardValue5.Selected.Value = [@'Timesheet Type'].'Sick', ["07"],
 [Parent.Default]))

 

 

 

DataCardValue5 = Timesheet Type combobox

[@'Timesheet Type'] = The choice/option set

 

So when I select "Holiday" in the Timesheet Type combobox, it shows the below:

 

timesheet holiday 1.PNG

But even though the combobox for Start Time Hour looks like "07" is selected, it actually isn't, and therefore when the timesheet is submitted these fields are left blank:

 

timesheet holiday 2.PNG

 

As you can see above, the combobox looks like 07 is selected, but when you click the dropdown you see it isn't.

 

Picture of submitted data:

 

timesheet standard 3.PNG

 

 

Does anyone have any ideas how to fix this?

 

I'm using Microsoft Dataverse to store my data in case that is relevant.

  • Omainesi Profile Picture
    92 on at
    Re: Combobox defaultselecteditems based on other combobox value

    Hi Gareth,

     

    Thanks for your reply.

     

    1) Yes I only want it to be a single selection, I have SelectMultiple set to false. Not sure what you mean with regards to "You can then use the Selected output, instead of SelectedItems output"

     

    2) The ComboBoxes specifically related to this problem are:

     

    Timesheet Type

    • Standard
    • Holiday
    • Sick

    Start Time Hour

    • 00
    • 01
    • 02
    • 03
    • 04
    • 05
    • 06
    • 07
    • 08
    • 09
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    Start Time Minute

    • 00
    • 15
    • 30
    • 45

    There are also Finish Time Hour and Finish Time Minute which mirror their Start Time counterparts

     

    3) It looks like you're passing "07" as a text value

    How would I go about telling the Start Time Hour combobox that I want it to select "07" as the choice?

     

    4) Presumably this means you have a table/array/source of string values

    Yes, see the above choice column "Start Time Hour"

     

    5) Do you mean that is the resulting record after submitting a form?

    Correct

     

    6) Hours seems like a single control/field - how is it being saved/put together?

     

    There are 4 comboboxes relating to time here:

     

    1. Start Time Hour
    2. Start Time Minute
    3. Finish Time Hour
    4. Finish Time Minute

    Each has its own corresponding choice/options set of the same title. 

     

    The user clicks the combobox dropdown and selects the hour they started, they then select the minute they started - identical for the finish time.

     

    This is how the hours are displayed when viewing the record:

     

    ThisItem.'Start Time Hour' & ":" & ThisItem.'Start Time Minute' & " - " & ThisItem.'Finish Time Hour' & ":" & ThisItem.'Finish Time Minute'

    The above code works fine.

  • GarethPrisk Profile Picture
    2,826 on at
    Re: Combobox defaultselecteditems based on other combobox value

    A couple of questions/points:

    • Presumably, you only want a single selection from the ComboBox
      • SelectMultiple should be false
      • You can then use the Selected output, instead of SelectedItems output
    • What is the Items of your ComboBox(es)?
      • It looks like you're passing "07" as a text value
      • Presumably this means you have a table/array/source of string values
    • When you say "Submitted Data"
      • Do you mean that is the resulting record after submitting a form?
      • Hours seems like a single control/field - how is it being saved/put together?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard