cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mpowis
Helper I
Helper I

Following tutorials but code has changed so form shows so many errors, i need help

I have been learning Power Apps and following some videos YouTube but it seems the code has changed because i cannot recreate their results.

I have a list on SharePoint, i then created an app linked to it in power apps as a gallery, i got the data inputting into text boxes from the list, i then added an edit icon and set it so when the edit icon is clicked it will edit that record using the ID, that all works fine but when i add a save icon i start to get invalid arguments.

 

Code for edit

 

If(ThisItem.ID=EditMode,false,true)

 

 

Code for Text boxes (DisplayMode)

 

If(ThisItem.ID=EditMode,DisplayMode.Edit,DisplayMode.View)

 

 

Code for Save 

 

UpdateContext({EditMode: ""}); Patch('Petty Cash Reimbursement',{ID=ThisItem.ID},{Description:In_Desc.Text,Students:In_Stu.Number,Staff:In_Staff.Number,'Cost Per Head': In_Cost.Number,Value:In_Val.Number,'Claimant Signature':In_C_Sign.Text,'Manager Signature':In_M_Sign.Text,Code:In_Code.Number})

 

 

As soon as i enter the code for Save the formulas error out saying Invalid argument type with the text inputs and Unexpected characters we expect an operator such as +,*'or & at this point in the formula.

 

thanks for your help... Power Apps Newbie

1 ACCEPTED SOLUTION

Accepted Solutions

You were so close, after more research and looking at your answer i tried the code many different ways and the one that finally worked was this:

 

pdateContext(Patch('Petty Cash Reimbursement',ThisItem,{Description:In_Desc.Text,Students:Value(In_Stu.Text),Staff:Value(In_Staff.Text),Value:Value(In_Val.Text),'Claimant Signature':In_C_Sign.Text,'Manager Signature':In_M_Sign.Text,Code:Value(In_Code.Text)}))

It may not be pretty but it works lol

View solution in original post

4 REPLIES 4
mahoneypat
Solution Sage
Solution Sage

Please try it with this small change in your Patch - {ID: ThisItem.ID}

 

UpdateContext({EditMode: ""}); Patch('Petty Cash Reimbursement',{ID: ThisItem.ID},{Description:In_Desc.Text,Students:In_Stu.Number,Staff:In_Staff.Number,'Cost Per Head': In_Cost.Number,Value:In_Val.Number,'Claimant Signature':In_C_Sign.Text,'Manager Signature':In_M_Sign.Text,Code:In_Code.Number})

 

Regards,

Pat

Mpowis
Helper I
Helper I

@mahoneypat sorry that change didn't work still as many errors

timl
Super User III
Super User III

@Mpowis 

Assuming that the save button should update the current record in the gallery, this is the formula that you should use.

Patch('Petty Cash Reimbursement',
      LookUp(ID=ThisItem.ID),      
      {Description:In_Desc.Text,Students:In_Stu.Text,
      Staff:In_Staff.Text,'Cost Per Head': In_Cost.Text,
      Value:In_Val.Text,'Claimant Signature':In_C_Sign.Text,
      'Manager Signature':In_M_Sign.Text, Code:In_Code.Text}
)

The patch function takes three arguments - the data source, the record to update, and the record details.

To specify the record that you want to update, we would call the lookup function.


Also, assuming that the controls that you specify such as In_Stu are text input controls, there is no such property as Number. If you want to retrieve a numeric value, you would need to refer to the value function: eg, Value(In_Stu.Text)

You were so close, after more research and looking at your answer i tried the code many different ways and the one that finally worked was this:

 

pdateContext(Patch('Petty Cash Reimbursement',ThisItem,{Description:In_Desc.Text,Students:Value(In_Stu.Text),Staff:Value(In_Staff.Text),Value:Value(In_Val.Text),'Claimant Signature':In_C_Sign.Text,'Manager Signature':In_M_Sign.Text,Code:Value(In_Code.Text)}))

It may not be pretty but it works lol

View solution in original post

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 Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Top Solution Authors
Top Kudoed Authors
Users online (2,172)