cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rickfear
Level: Powered On

Dropdown default to be user().FullName

Hi I have an app with 2 forms that are identical.  On one of the forms I need to change a dropdown so that it has a defualt value that is User().FullName, and to be hidden.  Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions
rickfear
Level: Powered On

Re: Dropdown default to be user().FullName

I HAVE SOLVED IT!!!!!!!!!!!!

in DefaultSelectedItems i put [Label10.Text} and it works.

 

i tried changing the text in the label to another employees name, and it changes the combobox.

 

Thanks for everyone's help.

View solution in original post

14 REPLIES 14
Highlighted
TimRohr
Level 10

Re: Dropdown default to be user().FullName

Yes... so long as the User().FullName is in the Items for that dropdown.

 

The default property would be: User().FullName

and

The Visible property would be: false

 

But I wonder why you need the dropdown at all? If it is going to be invisible, you don't need the functionality. If you are feeding this form from the other (where the person is picked), you could just pass it as a context variable during your navigate() statement, or, if you really needed a control to hold the data, you could use a label.

rickfear
Level: Powered On

Re: Dropdown default to be user().FullName

Thanks I'll give this a try.

I am building an absence and attendance tool, similar to the template app.  I have one form that the employee fills out (so i dont want them to be able to change the employee name), and one for a manager to complete (so they will need to select the employee).  Both of these once completed get added to the same sharepoint list, so i need the fileds to be the same.

TimRohr
Level 10

Re: Dropdown default to be user().FullName

The fields can be the same, but the controls don't necessarily have to be, right? Especially if the control is going to be invisible and not allow changes. In that case, it is easier (and shorter code) to reference a label. Just a thought.

rickfear
Level: Powered On

Re: Dropdown default to be user().FullName

I have added a label to the screen with the text User().FullName.  It is showing as my name.

In the default field for the employee name card i have entered Label9.Text.  i get the formula error "The property sxpects Record values, but this rile produces incompatible Text values."

rickfear
Level: Powered On

Re: Dropdown default to be user().FullName

Employee Name Default Issue.JPG

rickfear
Level: Powered On

Re: Dropdown default to be user().FullName

Hi all,

 

i'm still having no luck with this.

 

This is the last piece of the puzzle before i can get the app working correctly.

 

any help would be great.

rickfear
Level: Powered On

Re: Dropdown default to be user().FullName

snip 1.JPGSnip 2.JPG

 

Just to confirm that the data in my label, matches the data in the dropdown.  I want to have the default in the dropdown be the label text.

TimRohr
Level 10

Re: Dropdown default to be user().FullName

I think there is some confusion about what you are trying to accomplish. Here is what I understand about what you're trying to do. Correct me where I am mistaken.

 

You have 2 forms that are identical except for this one field.

One form will be accessed ONLY by managers.

The other form will be accessed only by NON-managers.

On the manager form, the Employee field should be editable (thus, a dropdown/combobox)

On the non-manager form, the Employee field should be non-editable (thus, a label)

 

EXPECTED BEHAVIOR: 

When a manager accesses the manager form, s/he can pick any of the employees in the dropdown (maybe, or maybe not, limited to their direct reports).

When a non-manager access the employee form, s/he should see their own name already in the Employee field (label), and should NOT be able to change it.

 

So when we are talking about the default item for a dropdown, we are ONLY talking about a manager accessing the manager form. (In fact, if Label9 (from your image) is supposed to be the label representation on the non-manager form, then you're conflating the use-cases and over-complicating things.)

 

One more point of clarification: if, in this narrow case of a manager accessing the manager form, you want to default the dropdown to be User().FullName, you are necessarily talking about the User who is using the app at run-time. That means, for your testing, you will be returning your own name. It also means that the manager will have the dropdown defaulting to their own name.

 

If all of that is right, then we are making progress. That's the understanding on which I am basing my help. So, moving on...

 

The non-manager form is easy: give the label for the Employee field a Default of User().FullName.

 

For the manager form...

Your thread mentioned a Dropdown, but your image is of a Combobox. This is very important because the Default for a Dropdown can be a text string, but your combobox is going to expect a record, as your error suggests. To return a record, you're going to need to do a First(Filter()) construction to get the right record returned for the default. From your image, it looks like it might be:

First(Filter(Choices('Leave Requests RF'.'Employee Name'),'Employee Name' = User().FullName)))

 

Again, this will look for a match against the current user's FullName field, and return the appropriate record from your datasource.

 

Give that a try, and post back.

 

COMPLETELY UNREQUESTED SUGGESTION:

Not to complicate things, but if you get this working, let me suggest you take it a step further. If the only difference between the 2 forms is this one field, then you can simplify your app and get this down to a single form (making later updates/enhancements easier to manage). Go with the combobox solution as we have worked it out, above, and have everyone navigate to this same form. In the button that would navigate TO this form, put your logic that determines if the user is a manager or not (previously, you would have used this to steer people to the appropriate form). Send the true/false to the form we are working on as a context variable, and let the combobox reference it in  the DisplayMode property.

 

Putting a fine point on it:

Button from previous form:

Navigate(LeaveRequestScreenName,ScreenTransition.None,{ShowEmpCombo: BooleanTestOfManagerStatus})

The orange part is what you would replace with your logic, provided that it returns a true/false type output. This could be checking a field (IsManager) in a record source (EmployeeList😞

First(Filter(EmployeeList,EmployeeName=User().FullName)).IsManager

 

Employee combobox DisplayMode:

If(ShowEmpCombo,DisplayMode.Edit,DisplayMode.View)

Doing this, everyone goes to the same form, and all of your edits are containted to this one thing. It also removes the combobox functionality (effectively disallowing changes) for non-managers, but preserves it for managers.

 

Try all of that and let us know.

 

(Or ask if something isn't entirely clear...)

TimRohr
Level 10

Re: Dropdown default to be user().FullName

The more I think about it, I would go the single form route.

 

Fix the combobox with the First(Filter()) construction, and set the DisplayMode appropriately (as described in the previous post).

 

That will save you a world of headaches, later.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 328 members 6,406 guests
Please welcome our newest community members: