cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RipCityNinja
Frequent Visitor

Populating Date/Time control from Choice control

Hello,

 

I am putting the finishing touches on my Service Desk app linked to a SharePoint list and can't get tickets to auto-populate with future due dates.  My goal is to populate the due date when a admin picks the priority from a choice(complex data type).  These tickets might also change in priority at a later time meaning the due date will need to recalculate.  It makes sense to use the DateAdd function in this case.  I am able to get this working outside the form control with dropdown and date picker controls and multiple If statements.

 

If(Dropdown1.Selected.Value = "1", DateAdd(Now(), 1),
Dropdown1.Selected.Value = "2", DateAdd(Now(), 5),
Dropdown1.Selected.Value = "3", DateAdd(Now(), 10))

RipCityNinja_0-1618587510627.png

The image above works great and adjusts the date according to the selection, but I don't get the same results when apply this formula to my form controls.  If anyone can offer a better approach here it would be much appreciated.

7 REPLIES 7
RandyHayes
Super User III
Super User III

@RipCityNinja 

What is it that you are seeing differently in the Form?  The concept is the same.

Can you elaborate more on the problem?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
Prakash4691
Resolver II
Resolver II

Hi @RipCityNinja ,

 

Try setting the "DefaultDate" property of the control inside form, this is just an example, modify according to your fields. 

 

If(DataCardValue7.Selected.'Full Name' = "Nancy Anderson (sample)", DateAdd(Now(), 15, Days), Parent.Default)

 

The only difference I see is, missing units in DateAdd formula, is it for months/days etc.

 

Make sure to modify the "Update" property of the control accordingly. To see the updated value in datasource.

 

 

Regards,

Prakash

@RandyHayes I apologize for not providing clearer details.

 

@Prakash4691 ,

Adding units has me closer to a fix, but when trying to add by only hours, it adds to both days and hours.

 

If(DataCardValue11.Selected.Value = "Low", DateAdd(Now(), 5, Days),
DataCardValue11.Selected.Value = "Normal", DateAdd(Now(), 1, Days),
DataCardValue11.Selected.Value = "High", DateAdd(Now(), 12, Hours),
DataCardValue11.Selected.Value = "Critical", DateAdd(Now(), 1, Hours))

 

This image shows when "High" has been selected, adding 10 Days and 12 hours.

RipCityNinja_0-1618596545447.png

 

Also, I'm not quite sure how to adjust the "Update" properties default value of:

DateValue1.SelectedDate + Time(Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value), 0)

 

Thank you both for your assistance.

RandyHayes
Super User III
Super User III

@RipCityNinja 

So, can you still explain what the issue is within the form?  You originally said that the logic you have would not work in a form.  Are you saying that date would not change if the other dropdown was changed?  Or are you saying that in relation to the datasource, things are not displayed properly or written properly?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 

 

The formula in my original post wasn't being accepted by PowerApps with numerous red underlines when applying to my form controls.  To be clearer, I am applying all formulas to the Control and not datacards within it.

 

As it stands now.  I seem to be getting different behaviors at different times so it's proving a bit difficult to articulate.  While the form is in New mode I have issues (Days and Hours changing when DateAdd function expresses hours), but when form is in Edit mode Days are not impacted by these same drop down selections to add only hours.

 

Regardless of what values are displayed, the SharePoint item is saved or updated successfully.

 

Apologize for the confusion.

RandyHayes
Super User III
Super User III

@RipCityNinja 

Okay, so let's focus on the properties of your controls.  First...they are all in the same datacard, correct?

 

Your formula changed though back in message #4 - before you were basing on values of 1, 2, 3, etc and in message #4 you have "Low", "Normal", etc.

 

So, tell me the following:

- What is the items property of DataCardValue11?

- What is the DefaultDate on the datepicker?

- What is the Items property of the Hours and Minutes controls? 

- What is the Default property of the Hours and Minutes controls ?

- What is the Default property of the datacard that these controls are in?

- What is the Update property of the datacard that these controls are in?

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes 

Yes, all properties are specific to the Date/Time Control.  At this time the "1", "2", and "3" values can be disregarded as I was working with those independently to test.

 

- What is the items property of DataCardValue11?

Choices([@'Help Desk Tickets'].Priority) //Choices in Priority Column are "Low", "Normal", "High", and "Critical"

- What is the DefaultDate on the datepicker?

Parent.Default  // I overlooked that my formulas were inside both the control and the date picker and fixed this.

- What is the Items property of the Hours and Minutes controls? 

Hours =["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]

Minutes

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"]

- What is the Default property of the Hours and Minutes controls ?

Hours = Text(Hour(Parent.Default),"00")

Minutes = Text(Minute(Parent.Default),"00")

- What is the Default property of the datacard that these controls are in?

If(DataCardValue11.Selected.Value = "Low", DateAdd(Now(), 5, Days),
DataCardValue11.Selected.Value = "Normal", DateAdd(Now(), 1, Days),
DataCardValue11.Selected.Value = "High", DateAdd(Now(), 12, Hours),
DataCardValue11.Selected.Value = "Critical", DateAdd(Now(), 1, Hours))

- What is the Update property of the datacard that these controls are in?

DateValue1.SelectedDate + Time(Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value), 0)

 

Your list of questions was exactly what I needed.  After reviewing each and correcting the Default property of the date picker this is now working!!  With that said, I'm always welcome to additional information to learn from 🙂 

 

Learning how to develop with PowerApps and learning how to discuss it are 2 different skills.  I appreciate @RandyHayes@Prakash4691, and the rest of the community for your patience as I continue to grow!  

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (25,747)