cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork Impactful Individual
Impactful Individual

Update variable after patch SharePoint column

Currently i have an issue.
I have a gallery that i uses a collection i made from a SharePoint list, I use a filter when i create this collection.

 

ClearCollect(RecordsTickets, Filter(SharePointList, RequesterEmail = varUser && Status.Value="Closed"))

 

On the item on the gallery i use  OnSelect = and i set multiple variables for the item and then navigates to screen2

 

Now to the issue i have.
I use Patch on Screen2 where i save a comment to a SharePoint column.
When i type something and click save what i have written should be displayed instantly meaning the variable for the item should be update. Now the only way that i found to do this is by doing a new ClearCollect using the exact same filter from that was used on Screen1 so it matches the item to update. And i have to do this twice and refresh at the same time to make it work. I'm pretty sure I'm doing this all wrong

 

 

If(
    !IsBlank(RichTextEditorComment_1.HtmlText),
    Patch(
           SharePointList, 
           varSelectedTicket, 
           {
               'Case Comments':  "<b>" &
Char(13) & Char(13) & User().FullName & "</b>" & "<br> <span style='font-size:12pt'>"& Text( Now(), "[$-en-US]yyyy/mm/dd hh:mm")&"</span> <br> " &
Char(13) & RichTextEditorComment_1.HtmlText & varSelectedTicket.'Case Comments'
           }
    )
);
Reset(RichTextEditorComment_1);
Refresh(SharePointList);
ClearCollect(RecordsTickets, Filter(SharePointList, RequesterEmail = varUser && Status.Value="Closed"))
Set(varSelectedTicket, Gallery1_1.Selected);
Refresh(SharePointList);
Set(varSelectedTicket, Gallery1_1.Selected);

 

 

3 REPLIES 3
WarrenBelz Community Champion
Community Champion

Re: Update variable after patch SharePoint column

Hi @JimmyWork .

Please see //comments below

If(
   !IsBlank(RichTextEditorComment_1.HtmlText),
   Patch(
      SharePointList, 
      varSelectedTicket, 
      {   
         'Case Comments':  "<b>" &
         Char(13) & Char(13) & User().FullName & 
         "</b>" & "<br> <span style='font-size:12pt'>"& 
         Text( Now(), "[$-en-US]yyyy/mm/dd hh:mm")&"</span> <br> " &
         Char(13) & RichTextEditorComment_1.HtmlText & 
         varSelectedTicket.'Case Comments'
      }
   )
);
Reset(RichTextEditorComment_1);
Refresh(SharePointList);
ClearCollect(
   RecordsTickets, 
   Filter(
      SharePointList, 
      RequesterEmail = varUser && Status.Value="Closed"
   )
)                              //should be ; semi-colon here
Set(varSelectedTicket, Gallery1_1.Selected);
Refresh(SharePointList);
Refresh(SharePointList);       //try refreshing twice - may need a timer in here 
Set(varSelectedTicket, Gallery1_1.Selected);

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

JimmyWork Impactful Individual
Impactful Individual

Re: Update variable after patch SharePoint column

Thank you @WarrenBelz 

But this does not solve the issue, the issue is my current solution will fail instantly if the filtering shows any different result on my collection. I even had the issue that it will start to show a different item as i refer to 

Gallery1_1.Selected

I would like to be able to just update variable with what was last submitted using ThisItem.Selected 

WarrenBelz Community Champion
Community Champion

Re: Update variable after patch SharePoint column

Hi @JimmyWork ,

To simplify this - you are

  1. Patching a SharePoint list
  2. Refreshing the list in PowerApps to pick up the updated data
  3. Collecting from the list to get all the User's closed tickets.
  4. Setting a Variable (record table) for the currently selected record
  5. Refreshing the list again
  6. Setting the Variable again the refreshed record (gallery selected)

Are the two bold bit the ones that do not change?

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,666)