web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / submitting 2 forms if ...
Power Apps
Unanswered

submitting 2 forms if total hours = over 8

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello!

I am having a ticket system where workers can clock-in during their worktime. The app looks like this: https://gyazo.com/c8761eaa962db09ceb8dff502ba24321


Database looks like this:
https://gyazo.com/bccfff0f750091f347877325f6d67d82
Whenever the column tijdtotaal of the day they are wanting to fill in a ticket, is higher than 8, I want it to make a new ticket with the rest of the hours. 

This is what we need to do: 

-Everytime a new ticket gets created, we need to filter the database on the date of today and see how many rows are there. It then needs to check if TijdTotaal is over 8. When it is over 8, I want it to match up exactly to 8. This may be confusing so I will explain it with a screenshot.

How it is now: https://gyazo.com/b979d3d96597e7eeb8a351dfd4b8a433
How it should look like: https://gyazo.com/f256e7f855acaf9419592bae5bbbe3ff

It needs to calculate it to 8 and use the rest of the time to make a new ticket with the same information as the last ticket. How can we get this?

Just using this code to send the form away: SubmitForm(EditForm1)



I hope I have explained this well enough, if I didn't, let me know and I will try and explain it better. 

Code we have tried right now: 

 

 

ClearCollect(colUrenRegistratie, Filter(
 UrenRegistratie,
 Datum = Text(
 Today (),
 "dd/mm/yyyyy"
 ) And varcurrentuser = Werknemer
 ));

With(
 {
 sumTijdTotaal: Sum(colUrenRegistratie,TijdTotaal)
 },
 With(
 {
 remainder: 8-Mod(sumTijdTotaal,8)
 },
 If(
 EditForm1.Updates.TijdTotaal<=8,
 SubmitForm(EditForm1),
 If( 
 !EditForm1.Valid,
 Notify("One or more fields in the form were not entered correctly.",NotificationType.Error),
 Patch(UrenRegistratie,Defaults(UrenRegistratie),EditForm1.Updates,{TijdTotaal: remainder});
 Patch(UrenRegistratie,Defaults(UrenRegistratie),EditForm1.Updates,{TijdTotaal: EditForm1.Updates.TijdTotaal-remainder});

 If(
 !IsEmpty(Errors(UrenRegistratie)),

 Notify("There was an error submitting the form and records may not have been submitted successfully.",NotificationType.Error);
 ResetForm(EditForm1);
 Navigate([@Overzicht],Fade)
 )
 )
 )
 )
)

 

Categories:
I have the same question (0)
  • Joel CustomerEffective Profile Picture
    3,224 on at

    So when a record is entered you want to submit another form? That is a lot of code for a low code app. I would offload the process go power automate and on create or update of the first record, have flow evaluate the dat submitted and if less than 8 hours roll it up to 8

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @jlindstrom,

    Thank you for your answer. The app needs to do way more than that. 

    If a ticket gets created thats over 8 hours, it needs to split it up. Let's say I make a ticket of 9 hours, it should split them up. 

    The first one would have 8 hours, second ticket would have 1 hour. 

    And then another one gets created with 8 hours, it will needs to get split again, first one has to be 7 hours (1 from the last ticket + 7 to make it 😎 

    Second ticket then gets 1 hour, the remainder. It would be helpfull to read all of the explanations above. 

  • Joel CustomerEffective Profile Picture
    3,224 on at

    So you have two general options: client side (build it into the app) or server side (use power automate)

     

    you can make your solution do way more than what you describe, my advice is be strategic about how you do it so you provide a performance experience.

     

     

  • Joel CustomerEffective Profile Picture
    3,224 on at

    If you are querying the database and splitting things up you probably want to move to patch rather then submit form.


    the reason I recommend patch vs submit form is because it allows you a lot more control, where submit simply saves the record.

     

    see mr Dangs video for more details https://youtu.be/IIzgkdu0Uxs

     

    and if you need bulk data operations such as splitting up existing records, that should typically be done as a background process

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    How would you do the full code then? @jlindstrom 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard