cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Labraham36
Helper II
Helper II

Generate restriction

Hello community!

 

I need help with the following: I have this formula in the record saving icon:

 

If (IsBlank (DateValue1_1); UpdateContext ({Enter_Date: true}); If (IsBlank (DataCardValue6_1); UpdateContext ({Enter_Hours: true}); If (DateValue1_1 exactin App_Hours.Date; UpdateContext ({No_Repeat_Dates: true}); SubmitForm (EditForm1) && Navigate ('Registry Update'; Fade))))

 

This formula evaluates several things in order to restrict incorrect data entry. This part of the code in particular: "If (DateValue1_1 exactin App_Hours.Date; UpdateContext ({No_Repeat_Dates: true});" evaluates whether a record already exists on that date and, if there is, prevents another record from being made on that date date, since by date the idea was that only one record can be entered. The problem is that now they have asked me to add a list field, being that now there can be several records per day, only that each record must correspond to only one status. Ex: For 01/01/2021 there may be a record with the status "Available", another with the status "Not available", etc. But what cannot be is the same day, have two equal states. How could I add that restriction? Thanks in advance!

 

Problema.png

3 REPLIES 3
RandyHayes
Super User
Super User

@Labraham36 

Your formula has some errors to it.

1 - you are referencing things like DataCardValue1_1.  This is a control...it is not a property.  You need to reference the property of that control that you would like to determine if it is blank.  So, if it is a TextInput for example, then IsBlank(DataCardValue1_1.Text) is what you need to use.

2 - same applies to the DateValue1_1...it is a control, you need to reference the actual property of the control which would be - DateValue1_1.SelectedDate

 

I hope this is helpful for you.

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you very much for the advice ! I will take them into account for a better performance of my App, but the truth is that the code is working correctly. My problem is that I don't know how to compare the date with each state now. Something like:

 

"If (DateValue1_1 exactin App_Hours.Date && DataCardValue6.Text exactin App_Hours.Process Type =" Prepared Guides "; UpdateContext ({No_Repeat_Dates: true});"

 

Although this formula does not work, what you should do is look in the date field if there is a record with that date, if there is, it looks for if there is a record with that status on that date, and if both conditions are met, it does not leave have the user add the record. I hope my problem has been understood a little better. In advance, thank you very much for your help and interest "

RandyHayes
Super User
Super User

@Labraham36 

Can you tell me more about that the context variables are for?

Also, what kind of column is Process?  You are now showing that in the formula where before you were looking at the Fecha (date) column for your comparison.  You need to match types properly in the formulas.  If you want to match for dates, then you need to use dates and not text.

 

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,405)