cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ryder
Helper III
Helper III

how to make a yes/no field on an existing field

Hello,

In the field "next appointment",

 

rdv.png

Screenshot_19.png


I'd like to have the opportunity to choose whether or not there's a next appointment.

 

  • If there is a next appointment I press Yes  ➡️ I have the possibility to choose the date as you can see at the moment.
  • If there is no next appointment I press No ➡️ a message indicating "no appointment is scheduled" is recorded.

 

thanks for your help,

2 ACCEPTED SOLUTIONS

Accepted Solutions
Drrickryp
Super User
Super User

Hi @Ryder 

Your screenshot shows that the field is required.  You must change this to not required as the field should be blank if no appt is required.  Unlock the card containing the date field.  Add a toggle control to the card and set the properties as follows:

FalseText: 'No future appt necessary'
TrueText: 'Make future appt'
OnCheck: 'UpdateContext({showappt:true})
Visible: !showappt
Default: false
Select all of the controls in the card and set their Visible properties to showappt

Set the OnVisible property of the screen to UpdateContext({showappt:false})

Set the OnSuccess property of the form to Reset(Toggle1)

Based on these instructions, when the screen is displayed, the toggle will show No future appt necessary. When the toggle is checked, then it will disappear and the date and time controls will become visible. Once the data in the form is saved, the toggle will reset back to No appt necessary and become visible when the screen is reopened. 

Annotation 2020-05-16 083157.jpgAnnotation 2020-05-16 083233.jpg

View solution in original post

Hi @Ryder 

I think we are getting closer.  Rather than mess with the Edit screen, what if you controlled the visibility in the Display form based on a date only being shown if it is in the future.  I'm guessing here but what if you set the Visible property of the date item in the display screen to Date >= Today().  As an alternative, The Visible property of the card in the Display form as  DateDiff(Today(),futureApptDate)>0
BTW, you shouldn't use "Date" as the name of a field because it is a reserved function in PowerApps and could lead to confusion.  Something like futureApptDate would be more appropriate. 

View solution in original post

8 REPLIES 8
Drrickryp
Super User
Super User

Hi @Ryder 

Your screenshot shows that the field is required.  You must change this to not required as the field should be blank if no appt is required.  Unlock the card containing the date field.  Add a toggle control to the card and set the properties as follows:

FalseText: 'No future appt necessary'
TrueText: 'Make future appt'
OnCheck: 'UpdateContext({showappt:true})
Visible: !showappt
Default: false
Select all of the controls in the card and set their Visible properties to showappt

Set the OnVisible property of the screen to UpdateContext({showappt:false})

Set the OnSuccess property of the form to Reset(Toggle1)

Based on these instructions, when the screen is displayed, the toggle will show No future appt necessary. When the toggle is checked, then it will disappear and the date and time controls will become visible. Once the data in the form is saved, the toggle will reset back to No appt necessary and become visible when the screen is reopened. 

Annotation 2020-05-16 083157.jpgAnnotation 2020-05-16 083233.jpg

hi @Drrickryp ,

 

It works perfectly! 😀


Thank you for your help and your time

@Drrickryp ,

I've just noticed a small detail on the other hand once I validate the form without indicating a date.

 

Screenshot_24.png


The result still shows me a date by default, should I adjust the "update" or something else not ?

@Ryder 

You will need to change the Update property to account for a blank date.  Something like

 

If(
    IsBlank(DateValue3.SelectedDate),
    Blank(),
    DateValue3.SelectedDate + Time(
        Value(HourValue3.Selected.Value),
        Value(MinuteValue3.Selected.Value),
        0
    )
)

 

Make sure you have removed the required property for the field or PowerApps will try to insert the current date and time in the field.

@Drrickryp ,

 

unfortunately the same result

Screenshot_26.png

Screenshot_27.png

Hi @Ryder 

I think we are getting closer.  Rather than mess with the Edit screen, what if you controlled the visibility in the Display form based on a date only being shown if it is in the future.  I'm guessing here but what if you set the Visible property of the date item in the display screen to Date >= Today().  As an alternative, The Visible property of the card in the Display form as  DateDiff(Today(),futureApptDate)>0
BTW, you shouldn't use "Date" as the name of a field because it is a reserved function in PowerApps and could lead to confusion.  Something like futureApptDate would be more appropriate. 

@Drrickryp ,

 

It's working!

 

a big thank you for your help and patience

De rien mon ami.

smiling.gif

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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