cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SandraAkujobi
Post Partisan
Post Partisan

Struggling with Patch Function

I've been trying to use patch function to patch several screens. I've gotten to some extent but still finding it difficult.

It's quite different in my case as I i'm creating a timesheet and each edit screen represents days of the week which I'm trying to use patch to collect all entries as one form and instead of putting the patch formula on the submit icon, I have it on the clock in and out buttons on each screens. 

The formula I'm using for the clock in button keeps showing an error:

 

Set(VARmoncurrentdateandtime, Now());
Set(
    SubmittedRecord,      // save the 'Check In' record into a variable
    Patch(
         WeeklyTimeSheet2,
         Defaults(WeeklyTimeSheet2),
         {
          Title: ID.Text,
          Employee_name: empname.Selected,
          Contract_no: contr.Selected, ApprovalStatus:Approve.Selected,
          ClockIn: MonDay.SelectedDate + Time(Value(MonHour.Selected.Value), Value(MonMin.Selected.Value), 0),
          ClockOut: MonEndDay.SelectedDate + Time(Value(MonEndHour.Selected.Value), Value(MonEndMin.Selected.Value), 0)
         }
     )
)

 

when putting the formula for the clock out is that where I would now add in the lookup feature. For the other days how would I cry on with the formula so that entries would be stored as one, because from previous tries they keep storing as individual entities also when I submit one entry I get an approval request for that one entry instead of the whole weekly entry.

 

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @SandraAkujobi :

Sorry, I don’t understand your needs.

Could you tell me:

1\What is your problem?

  • Solve the error?(the clock in button keeps showing an error)
  • Store the entries  as one?(that entries would be stored as one)

2\What is the error?(the clock in button keeps showing an error)

3\What is the meaning of "entries would be stored as one"?

4\What is WeeklyTimeSheet2's data structure?

5\What are you going to achieve with this app?

Best Regards,

Bof

@v-bofeng-msft 

The whole purpose of the app is to collect employees daily timesheet entries and then by the end of the week the entries will be sent out as one weekly form to their respective manager to view and approve. 

Right now the single form is packed with information that need to be put in by the employees for each separate days like contract number, activity,clock in and out etc so I separated each day by screens to make it that each day would have their own form to make it look more presentable. The issue with that is that whenever they put in their entries for each day, they are each stored as one individual entry instead of just being in one form for the week. Which is why I was told to use patch. But it's been very hard to do. there hasn't been a change with the formula at all.  I'm not sure if it's the patch formula I'm using or not. All these information are stored in the sharepoint list for the weeklytimesheet.

 

This is actually the correct formula used for the actual app. there is no error shown here but the issue is that the entries are being stored twice, so when you clock in the time is stored incorrect, and when you clock out the entries stores again as another entry instead of being in the same form but then it's stored as the right time. As you can see in the two images below.

Set(VARmoncurrentdateandtime, Now());
Set(
    SubmittedRecord,      // save the 'Check In' record into a variable
    Patch(
         WeeklyTimeSheet,
         Defaults(WeeklyTimeSheet),
         {
          Title: ID.Text,
          Emp_Name: EmpName.Selected,
          Mon_Activity: MonAct.Selected,
          Mon_Contract: MonContract.Selected,
          Mon_Start: MonDay.SelectedDate + Time(Value(MonHour.Selected.Value), Value(MonMin.Selected.Value), 0),
          Mon_End: MonendDay.SelectedDate + Time(Value(MonendHour.Selected.Value), Value(MonendMin.Selected.Value), 0)
         }
     )
)

 Screenshot (221).pngScreenshot (222).png

Hi @SandraAkujobi :

Let me sort out the logic, if there are any errors, please help me point out:

  • There are five screens and each screen have a new from.
  • Employees fill out a form every day and submit the contents of the five from at the same time on the last day.
  • The contents of these 5 from will be saved as one record into the SP list.

If my understanding is correct:

  • How are you going to summarize these records into one record? What is its data structure?
  • What is the data structure of the data source SubmittedRecord?

Best Regards,

Bof

@v-bofeng-msft 

Yes so there are 6 screens and each screen represents each day except for the 6th screen that has Saturday and Sunday on it together. Employees will fill out the form for the day they are on. Exactly the contents of these 6 forms will be saved as one record into the SP list. 

Initially the form had all the days on it which looked untidy, which is why I created separate screens for them. I was thinking of using patch to summarise each records into one form. 

 

Title is text.

Activity for each day is a choice column.

Employee is Person/Group column.

Contract is a Lookup column.

Start and End times for each day is date/time field.

 

Screenshot (229).pngScreenshot (230).png

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,105)