cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sam4
Level: Powered On

Edit/Create an item in a SharePoint List based on gallery based on Gallery - ForAll, Patch and If

Hi, I'm stuck in a formula getting some errors so not really sure if it is possible to achieve what I want. The formula is using ForAll, If and Patch to update some items from a gallery in a SharePoint List.

 

The SP List, MySPList, has 3 columns: SPID (This number is a variable IDVar), Type and Impact

The Gallery1 has 3 elements.

  • Item_Check (Check box)
  • Item_Type (Label - Number)
  • Item_Impact (TextInput)

The Gallery is a filtered gallery of all Types from MySPList where SPID=IDVar

 

The functionality is, when I click on a button, all elements of the Gallery checked (Item_Check=true) should be either updated or created depending if they previously exist. What I'm doing is a lookup to find the item by SPID and Type and if it is empty, create the item with Patch, otherwise edit with Patch.

 

The code is something like that but first, it is not working and secondly I'm getting some delegation errors (that i dont know why) I

 

FORALL(Gallery1.AllItems,
  IF(Item_Check=True,
    IF(!IsBlank(LookUp(MySPList,SPID=IDVar && Type = Value(Item_Type.Text))),
      Patch(MySPList,LookUp(MySPList,SPID=IDVar && Type = Value(Item_Type.Text)){SPID:IDVar, Type: Item_Type, Impact:Item_Impact}),
      Patch(MySPList,Defaults(MySPList),{SPID:IDVar, Type: Item_Type, Impact:Item_Impact})))

  

 

any help is welcome

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Sam4
Level: Powered On

Re: Edit/Create an item in a SharePoint List based on gallery based on Gallery - ForAll, Patch and If

Spoiler
I'm replying to myself as I've been able to progress with this so leaving the reply if that can help someone.

I had two problems:

- Delegation: I've solved taking out the LookUp of the FORALL and adding a non-visible item in the gallery with the SP ID. Then in the ForAll I'm using this item to identify where I am updating the data

- Sintaxis: Several errors fixed. The code finally stays like this

ForAll(Gallery1.AllItems, 
  If(Item_Check.Value=true, 
    If(IsBlank(ItemSPID.Text),Patch(MySPList,Defaults(MySPList),{SPID:IDVar, Type: Item_Type, Impact:Item_Impact.Text}),Patch(MySPList,{SPID:IDVar, Type: Item_Type, Impact:Item_Impact.Text}))))​



View solution in original post

1 REPLY 1
Sam4
Level: Powered On

Re: Edit/Create an item in a SharePoint List based on gallery based on Gallery - ForAll, Patch and If

Spoiler
I'm replying to myself as I've been able to progress with this so leaving the reply if that can help someone.

I had two problems:

- Delegation: I've solved taking out the LookUp of the FORALL and adding a non-visible item in the gallery with the SP ID. Then in the ForAll I'm using this item to identify where I am updating the data

- Sintaxis: Several errors fixed. The code finally stays like this

ForAll(Gallery1.AllItems, 
  If(Item_Check.Value=true, 
    If(IsBlank(ItemSPID.Text),Patch(MySPList,Defaults(MySPList),{SPID:IDVar, Type: Item_Type, Impact:Item_Impact.Text}),Patch(MySPList,{SPID:IDVar, Type: Item_Type, Impact:Item_Impact.Text}))))​



View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,491)