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

New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

Hello

I am creating a new form and I want one of the drop-down list to be pre-selected with a default value.

 

This list contains dates (in the format of strings), which are Mondays of each week (refer to the attached screenshot). This list is based off a separate SharePoint list (only containing dates), that is looked up by the SharePoint list that is the basis of this form.

 

I want the default value to be the Monday of the following week from today. For example, today is 2020-02-05 (Wednesday). I want the pre-populated default item to be 2020-02-10.

 

I have tried writing the following code in the Default field in the DataCardValue I am interested in, but this doesn't seem to work:

 

 

LookUp(
    
    Choices('Activity List'.Week),
Value=Text(Today() + 7 - Weekday(Today(), MondayZero),"[$-en-AU]yyyy-mm-dd"))

 

 

I would welcome and appreciate any help. Also as this is my first post, just a quick shout out to all users who have been posting and answering questions. This is a very good resource for general queries.

 

Many thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
southern_cross
Level: Powered On

Re: New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

Thanks for your reply @eka24 . I realise my message has been rather vague. I was able to figure out a solution, but your code has given me ideas for future functionalities in my app, so thank you.

 

To those who come across this issue, my solution to a scenario - where I have a drop-down combo list of dates (which are strings) and I want to pre-populate (i.e. set DefaultSelectedItems) the field with the nearest future date - by setting DefaultSelectedItems to:

 

 

 

Filter(Choices([@'Activity List'].Week),Value=First(Filter('Weeks List',Week > Today())).Weeks)

 

 

Where 'Week' in the 'Weeks List' contain dates that are in the proper date format (dd/mm/yyyy).

 

Hopes this helps anyone who is coming across this unique problem. Thanks

View solution in original post

5 REPLIES 5
eka24
Level 10

Re: New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

LookUp(
Choices('Activity List'.Week),
Text( DateAdd( Now(), 7 ),
"dd-mm-yyyy" )))
southern_cross
Level: Powered On

Re: New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

Hi @eka24

 

Thanks for your reply.

 

As I understand it, the dateadd function only adds 7 days ahead to whatever now() is right?

 

However what I want is for the pre-populated value to be the Monday of the following week, which would correspond to one of the items in the lookup list, in the yyyy-mm-dd format (refer to attached picture in the main post; this format helps in sorting the dates chronologically).

 

Is there any way to achieve this?

 

Thanks

eka24
Level 10

Re: New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

  1. Insert  Dropdown2_1 set it Items to 'Activity List'.Week
  2. Insert a DatePicker1 and set its DefaultDate to Dropdown2_1.Selected.Week (You can also use a combobox. Set the visible of the Datepicker1 to false since users will not interact with it.
  3. In the Textbox the that you want the lookup:
    Text(DateValue(Text(DatePicker1.SelectedDate))+

          (9-Weekday(Today(),MondayZero)),"[$-en-US]yyyy-mm-dd")

 

See Attached

 

Please click and accept as Solution if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

747_Warrior
Level: Power Up

Re: New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

[Delete]

southern_cross
Level: Powered On

Re: New Form - Pre-populated (Default) Drop-Down Item Based on Today's Date

Thanks for your reply @eka24 . I realise my message has been rather vague. I was able to figure out a solution, but your code has given me ideas for future functionalities in my app, so thank you.

 

To those who come across this issue, my solution to a scenario - where I have a drop-down combo list of dates (which are strings) and I want to pre-populate (i.e. set DefaultSelectedItems) the field with the nearest future date - by setting DefaultSelectedItems to:

 

 

 

Filter(Choices([@'Activity List'].Week),Value=First(Filter('Weeks List',Week > Today())).Weeks)

 

 

Where 'Week' in the 'Weeks List' contain dates that are in the proper date format (dd/mm/yyyy).

 

Hopes this helps anyone who is coming across this unique problem. Thanks

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,988)