0

How to update using patch in SharePoint list from edit form?

Using below patch function. but, its creating new record every time.

When I select an item from the gallery and edit it, creates a new item what's the problem?

Patch Code:

If(DataCardValue1.Selected.Value = "Time Off",
Patch(
   LeaveRequests,
   Defaults(LeaveRequests),
   {
   LeaveID: CurrentUserID,    
   User:     DataCardValue6.Text,
   UserEmail:
   {
 Claims: Concatenate(
          "i:0#.f|membership|",
          DataCardValue3.Selected.Email // Person email
          ),
          Department: "",
          DisplayName: "",
          Email: User().Email, // Person email
          JobTitle: "",
          Picture: ""

   },

   Description: DataCardValue2.Text,
   TimeOffDate: DataCardValue22.SelectedDate,
   TimeOffFrom: DataCardValue19.Selected,
   TimeOffTo: DataCardValue20.Selected,
   TotalTimeRequested: Label23.Text
   
    }
  )
); Navigate(SucessScreen,None)
0

Use patch as below. You are proabably using Defaults() as second parameter to your patch function.

Patch(DataSource, {ID:selectedGalleryItem.ID},{Title:'UpdatedValue'});
5
  • Yes, I am using Defaults(ListName) and then the code. What's the difference between Defaults and Gallery.Selected ? will it still create new record? and edit them accordingly?
    – Tera Byte
    Jul 22 '20 at 11:47
  • defaults tells powerapps to create a new item, while passing in ID parameter as i did helps powerapps lookup the item that needs to be updated Jul 22 '20 at 11:48
  • Ok, Let me check it out first, do I have to create a new Numeric Id field? in my List?
    – Tera Byte
    Jul 22 '20 at 11:49
  • no every list has a ID field built in as auto incrementing field with unique values. It may be hidden in view but you can added it to the view by editing the view Jul 22 '20 at 11:50
  • Thankyou Sir @Akshay, you solved my problem. Cheers
    – Tera Byte
    Jul 22 '20 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.