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

Time is not saving in to database

Hi there, 

I'm struggling to save information on a line and patch mot of the information from that line to another line.

To be more exact, a have a line with an allocated job . This line has a Start and a Stop beside other general info.

If I can't finish today the job, I need to be able to save what I have done today (start and stop) and create another line for tomorrow with all the necessary info.

Problem is that it's not saving the start and stop time for the time spent in the job; it's copying the line to another line.

please what am I doing wrong ?

thanks 

 

SergiuTPLS_1-1633940650771.png

 

SubmitForm(EditForm1);
Set(varTimpRamas,ThisItem.TimpAlocat-ThisItem.TimpEfectivMinute);

Patch(CentralizareTLSC2021, Defaults(CentralizareTLSC2021),
{Masina:DataCardValue32.Selected,
Lucrare:DataCardValue11.Selected,
Utilaj:DataCardValue12.Selected,
Operator:DataCardValue5.Selected,
TimpAlocat:varTimpRamas,
CompetentaLucrare:DataCardValue6.Selected,
ObservatiiLucrare:DataCardValue31.Text}
);
UpdateContext({vStopTime:true});
Set(varstopvizibil,false);
Set(varstartvisibil,true);

 

5 REPLIES 5
Nogueira1306
Super User
Super User

Hey!

 

If you use "Defaults(CentralizeTLSC2021)" it willl ALWAYS create a new line.

 

Do this:

 

SubmitForm(EditForm1);
Set(varTimpRamas,ThisItem.TimpAlocat-ThisItem.TimpEfectivMinute);

Patch(CentralizareTLSC2021, LookUp(CentralizareTLSC2021, ID = ThisItemID),
{Masina:DataCardValue32.Selected,
Lucrare:DataCardValue11.Selected,
Utilaj:DataCardValue12.Selected,
Operator:DataCardValue5.Selected,
TimpAlocat:varTimpRamas,
CompetentaLucrare:DataCardValue6.Selected,
ObservatiiLucrare:DataCardValue31.Text}
);
UpdateContext({vStopTime:true});
Set(varstopvizibil,false);
Set(varstartvisibil,true);

 

That will update instead of creating a new Line

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

Hi, thanks for the quick reply.

I need both lines, the old one for that I can't save start time and stop time, and the new created line with the same info but without the start and stop.

My problem is that when duplicating the current line(by using patch), the Start and Stop values are not being saved.

 

Why dont you use a form? Using form, you dont need Patch, jsut submit form and, if you u are using sharepoint as your database, you dont need to add the fields. 
Plus, you can edit.

 

If you want to use patch, first you need to check if the register exist or not, something like this:

 

If(CountRows(Filter(CentralizeTLSC2021, ID = ThisItem.ID)) >= 1,

 

Patch(CentralizareTLSC2021, LookUp(CentralizareTLSC2021, ID = ThisItemID),
{Masina:DataCardValue32.Selected,
Lucrare:DataCardValue11.Selected,
Utilaj:DataCardValue12.Selected,
Operator:DataCardValue5.Selected,
TimpAlocat:varTimpRamas,
CompetentaLucrare:DataCardValue6.Selected,
ObservatiiLucrare:DataCardValue31.Text}
),

 

Patch(CentralizareTLSC2021, Defaults(CentralizareTLSC2021),
{Masina:DataCardValue32.Selected,
Lucrare:DataCardValue11.Selected,
Utilaj:DataCardValue12.Selected,
Operator:DataCardValue5.Selected,
TimpAlocat:varTimpRamas,
CompetentaLucrare:DataCardValue6.Selected,
ObservatiiLucrare:DataCardValue31.Text}
)

);

 

So if it exists, you update, if not, you create.

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

I am using a form, but from the same form I can either Start and Stop the allocated job or a can Start it and choose to end it now and continue it tomorrow.

when I start and stop today and finish, everything is ok, but when i choose to continue it tomorrow I need to save this job/time spent today and copy the job details to another line on that i will start working tomorrow.

For ex: a allocate 30 minutes today to you in order to write 5 procedures, you enter the app see the allocated job, press start but after 20 minutes you press stop because you have finished your program for today. you still need to work on this job tomorrow for the last 10 minute so what you have done today it is saved in the list with start, stop ( 20 minutes ) and tomorrow when you come to work you will have in your job list the rest of the 10 minute to do with all the job information.

 

this is what I was trying to do with the patch, create the line for tomorrow, but also on the same button to submit the form and save the start and stop times.

it does all except saving the start and stop for today

I am using a form, but from the same form I can either Start and Stop the allocated job or a can Start it and choose to end it now and continue it tomorrow.

when I start and stop today and finish, everything is ok, but when i choose to continue it tomorrow I need to save this job/time spent today and copy the job details to another line on that i will start working tomorrow.

For ex: a allocate 30 minutes today to you in order to write 5 procedures, you enter the app see the allocated job, press start but after 20 minutes you press stop because you have finished your program for today. you still need to work on this job tomorrow for the last 10 minute so what you have done today it is saved in the list with start, stop ( 20 minutes ) and tomorrow when you come to work you will have in your job list the rest of the 10 minute to do with all the job information.

 

this is what I was trying to do with the patch, create the line for tomorrow, but also on the same button to submit the form and save the start and stop times.

it does all except saving the start and stop for today

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.

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,435)