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

block duplication

Hello, I had a little problem with how I can ensure that we do not have the Name and year column having both the same value at the same time, because a person can evaluate himself once a year and not several times and if by forgetting the person wants to evaluate himself for the second time during the year that the recording is not taken into account with error message.
 
If (CountRows (ColEvaluation)> 0;
ForAll (ColEvaluation; Patch ('EVALUATION'; Defaults ('EVALUATION');
{Name: NAME; age: AGE; job: JOB; year: YEAR OF EVALUATION;
score: SCORE; salary: SALARY } ) ) ) ;;
Capture.PNGClear (InventoryCol) ;; Notify ("Your Data's saved successfull"; NotificationType.Success)
 
 
 
 
2 REPLIES 2

@Peter_93 

 

After the ForAll you will need an If - check if the current value is already the same as the current year. If so, have it just be false so the  Patch is not performed for that row. Otherwise, do the Patch.

 

A rough example (not exact, change it to make sense):

 

 

If (CountRows (ColEvaluation)> 0;
ForAll (ColEvaluation; If(year = Year(Now()),false,Patch ('EVALUATION'; Defaults ('EVALUATION');
{Name: NAME; age: AGE; job: JOB; year: YEAR OF EVALUATION;
score: SCORE; salary: SALARY } ) ) ) ) ;;

 

The above example will probably not work as given, it is for rough illustration only, you can check it and change it to make sense for you.

 

 

If you must show an error message, you can replace false above ion the If(year = Year(Now()),false,... with something like Notify or some formula that shows error message if the user should be advised what row(s) was/were not saved.

 

Check if above helps.

Peter_93
Frequent Visitor

Thank you Sir for the answer, By the way the Current year can exist so many times but not at the same time the same name and the same year at the same to avoid an evaluation 2 times, because there can be several times the same year to repeat and the name of the person too

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (1,885)