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

Patch Funtion not working

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

I know that with the patch function would be used on the submit button for collection of new data entries. 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. 

On the Monday screen this is the formula used on the clock in button, which seems to work but after clicking on it an error sign appears on the button which can be seen in the 2nd image. There is no error message for this on the right hand side.

Screenshot (176).pngScreenshot (180).png

 

Then on the clock out button, the formula is completely off and this is the same for the Tuesday clock in/clock off button.

Screenshot (184).pngScreenshot (183).png

13 REPLIES 13
BrianS
Super User
Super User

I'm not sure why the first instance isn't throwing an error, but they all look like the same problem. You are trying to Patch the input itself instead of the text or value of the control. Just add a ".Text" or ".Value" after each of the fields - {Emp_Name:EmpName.Text, ...}.

That should fix the issue, if not let us know the new error message

I tried what you said, but it didn't seem to work.

 

Screenshot (186).png

 

I put it back to former formula and as previously it works but after clicking the error sign is shown.

Screenshot (187).png

 

 

The Monday Clock Out button just doesn't work at all, whether the formula you said I should use or the one I used before.

Screenshot (185).png

The Text needs to be capitalized. After yo put the "." in there should be a list of appropriate possible values you can pick from. Also the additional property is missing from the date fields.

Hi @SandraAkujobi ,

Could you please share more details about the 'Emp_Name' field, Mon_Activity field, Mon_Contract field in your SP List? Are they all Choice type column?

Could you please show a bit more about the 'Mon_Start' and 'Mon_End' field in your SP List? Are they both Date time type column?

 

If the 'Emp_Name' field, Mon_Activity field, Mon_Contract field are all Choice type columns in your SP List, I think the value formula you provided for them in your Patch function is correct.

 

If the 'Mon_Start' and 'Mon_End' field are both Date time type column in your SP List, I think thee is something wrong with the value you provided for the 'Mon_Start' and 'Mon_End' column in your Patch function. You should modify your formula as below:

Set(VARmoncurrentdateandtime, Now());
Patch(
      WeeklyTimeSheet,
      Defaults(WeeklyTimeSheet),
      {
        Title: ID.Text,
        Emp_Name: EmpName.Selected,
        Mon_Activity: MonAct.Selected,
        Mon_Contract: MonContract.Selected,
        Mon_Start: DatePicker1.SelectedDate + Time(Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value), 0),
        Mon_End: DatePicker2.SelectedDate + Time(Value(HourValue2.Selected.Value), Value(MinuteValue2.Selected.Value), 0)
      }
)

Note: The DatePicker1 represents the DatePicker control within the Mon_Start field data card (HourValue1, MinuteValue1 represents the Dropdown controls inside same data card), and the DatePicker2 represents the DatePicker control within the Mon_End data card (HourValue2, MinuteValue2 represents the Dropdown controls inside same data card).

 

Regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I'll try this now and see how it works; so for the clock out button instead of using default would it be replaced with "lookup" but then follow the same formula after that and the same with the other day screens.

Hi @SandraAkujobi ,

Have you tried the solution I provided above? Is it helpful?

 

If you have solved your original problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

If you still have issue with your scenario, please feel free to let me know here, or you could also consider open another new thread and describe your issue there.

 

Regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

'Emp_Name' field is a person or a group field, Mon_Activity is a choice field and Mon_Contract is a lookup field. List'MonStart' and 'Mon_End' are both a date time fields in he SP list. 

 

For the Tuesday and Wednesday so on screens how would I add in the patch function, only then would I know that they would I know whether it's worked well. All the other screen have the same fields are the Monday screen except for Title and Emp_Name as they work as one form so the first screen should have that which is Monday.

Hi @SandraAkujobi ,

Is there some error message with the formula I provided above?

Have you solved your problem?

 

Regarding the needs that you mentioned, I think the solution I provided above could achieve your needs. Please try it, then check if the issue is  solved.

 

Regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The formula didn't work, instead it was coming out as individual entries instead as one entry. Also the datepicker were only available for the Monday form, for the other forms there were none. So I was quite confused in regards to the date/time.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (20,240)