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

Set default value for a combobox

I'm creating an app for tracking visitors to our various facilities.  I added a single SharePoint online list. There are 3 special columns that I need help with.

  • a choice field for Building which is a required field
  • a Yes/No field for Check out
  • a date/time column for check-out date & time

I'm planning on creating separate apps for each building.  Right now I just have the one app for our Corporate Office. They will all have a different Welcome screen with a picture of the building and a "Welcome to ____________ (name of building). The welcome screen will have 2 buttons: check-in, check-out. The Check-in button does a newform. (The create date/time field serves as the check-in date/time field.) 

 

On the Newform, I want it to default the building value when new list items are added.  But I can't figure out how to assign the default value to the building column.  Originally, the combobox had Parent.Default for the Default property.  I tried changing it to "Corporate Office" but that didn't work.  I then tried If( IsBlank(Parent.Default),"Corporate Office", Parent.Default) but I'm getting invalid argument type (Record). Expecting a text value instead.

 

So #1 I need help with setting a default value.

 

The check-out button will go to a browse screen that is filtered to display only users where Checkout is false (yes/no field) and Building="Corporate Office".  (This is working) You then select a person on the list and it brings up an edit form.  All the user has to do is change the slider on the check-out button and save.  When they set the slider to yes/on, I would like it to populate the checkout date/time column automatically.

 

So #2, I need direction on how to go about automatically populating the date/time when the slider is turned on.

 

My preference is to display the check out time on the screen in case the visitor left by a different door and the receptionist has to guess on the time, thereby overriding the automated check out time value.  If this isn't feasible, I'll leave the check out date/time off the screen and create a flow to update the time.  The receptionist will have to access the list to correct the time (which is probably not likely to happen.)

 

The actual SharePoint list will be used for exception handling, querying who has visited, finding visitors regardless of building they are in, etc.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Set default value for a combobox

Hi @forbesn

 

For #1

I suggest using simple text column in SharePoint list and not Choice filed. It will work way better. You can add a custom DropDown which will populate the SharePoint list with only values you allow. The Items in the dropdown can be added manually or from excel list.

 

For #2

 

Assuming you have checkout time column in your SharePoint list you can add this function to your Submit button (the one that submits the form) just before the SubmitForm() action:

 

UpdateContext(
  {
    _CheckOutTime:Now()
  }
);

Now add the Checkout time datacard in the form and change its Default to

_CheckOutTime

Now you can make this datacard invisible since people will not be entering anything here.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Re: Set default value for a combobox

Hi @forbesn

 

For #1

I suggest using simple text column in SharePoint list and not Choice filed. It will work way better. You can add a custom DropDown which will populate the SharePoint list with only values you allow. The Items in the dropdown can be added manually or from excel list.

 

For #2

 

Assuming you have checkout time column in your SharePoint list you can add this function to your Submit button (the one that submits the form) just before the SubmitForm() action:

 

UpdateContext(
  {
    _CheckOutTime:Now()
  }
);

Now add the Checkout time datacard in the form and change its Default to

_CheckOutTime

Now you can make this datacard invisible since people will not be entering anything here.

 

View solution in original post

Highlighted
forbesn
Level: Powered On

Re: Set default value for a combobox

Thanks.  Those suggestions helped.

 

I ran into one other issue.  It appears that Powerapps is saving the time as Pacific and I am in Central time zone. (time is -2 hours off when displayed in SharePoint but is correct when viewed on the app.)  There are numerous posts on this issue. 

 

Right now most of our offices are in central time zone so I could just add 2 hours to all my time fields when I save them then when I display them in Powerapps I have to subtract 2 hours but it will be right in SharePoint. 

 

Since each office will have a unique app that can pretty much be handled in the code except that for the Check In time I was using the Created column.  Is there a way to adjust the value in that coumn?  If not, I guess I add a new column and default the time to the save time (+2 hours) on the check in form.

 

Another solution I have seen is to save everything back to UTC time but it doesn't look like it will be any less work - it appears it will actually be more work since I'll have to convert the display times in Powerapps and SharePoint.

 

Is Microsoft working on a solution for that?

 

 

 

 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,571)